Kill generic typevar modelling

Reviewed By: da319, dulmarod

Differential Revision: D7845719

fbshipit-source-id: a8ae68f
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 3a3c871684
commit 3ef6cb1c75

@ -1,34 +0,0 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <vector>
namespace folly {
#define TYPEVAR(Name) \
struct __attribute__((annotate("__infer_type_var"))) Name {};
TYPEVAR(a1);
TYPEVAR(a2);
TYPEVAR(a3);
template <class Delim, class String, class OutputType>
void split(const Delim& delimiter,
const String& input,
std::vector<OutputType>& out,
bool ignoreEmpty = false) {
out.resize(1);
return;
}
template __attribute__((annotate("__infer_generic_model"))) void
split<a1, a2, a3>(const a1& delimiter,
const a2& input,
std::vector<a3>& out,
const bool ignoreEmpty);
}

@ -240,19 +240,13 @@ let rec get_struct_fields tenv decl =
(** For a record declaration it returns/constructs the type *) (** For a record declaration it returns/constructs the type *)
and get_record_declaration_type tenv decl = and get_record_declaration_type tenv decl =
let definition_decl = get_record_definition decl in let definition_decl = get_record_definition decl in
match get_record_custom_type tenv definition_decl with match get_record_friend_decl_type tenv definition_decl with
| Some t -> | Some t ->
t.Typ.desc t.Typ.desc
| None -> | None ->
get_record_struct_type tenv definition_decl get_record_struct_type tenv definition_decl
and get_record_custom_type tenv definition_decl =
let result = get_record_friend_decl_type tenv definition_decl in
let result = if Option.is_none result then get_record_as_typevar definition_decl else result in
result
and get_record_friend_decl_type tenv definition_decl = and get_record_friend_decl_type tenv definition_decl =
let open Clang_ast_t in let open Clang_ast_t in
match definition_decl with match definition_decl with
@ -263,24 +257,6 @@ and get_record_friend_decl_type tenv definition_decl =
None None
and get_record_as_typevar (definition_decl: Clang_ast_t.decl) =
let open Clang_ast_t in
match definition_decl with
| CXXRecordDecl (decl_info, name_info, _, _, _, _, _, _) ->
let is_infer_typevar = function
| AnnotateAttr {ai_parameters= [_; name; _]} when String.equal name "__infer_type_var" ->
true
| _ ->
false
in
if List.exists ~f:is_infer_typevar decl_info.di_attributes then
let tname = CAst_utils.get_qualified_name name_info |> QualifiedCppName.to_qual_string in
Some (Typ.mk (TVar tname))
else None
| _ ->
None
(* We need to take the name out of the type as the struct can be anonymous (* We need to take the name out of the type as the struct can be anonymous
If tenv is not passed, then template instantiaion information may be incorrect, If tenv is not passed, then template instantiaion information may be incorrect,
as it defaults to Typ.NoTemplate *) as it defaults to Typ.NoTemplate *)

Loading…
Cancel
Save