[clang] use a more efficient `var_decl_info`

Summary:
Update plugin to take into account that some fields of VarDecl were unused by
infer. Also, use a boolean holding `hasExternalStorage` instead of comparing to
the fragile (and probably not entirely accurate) `"extern"` string.

update-submodule: facebook-clang-plugins

Reviewed By: mbouaziz

Differential Revision: D6231836

fbshipit-source-id: 3c0a75b
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 525a94e470
commit ed55fc63f2

@ -1 +1 @@
Subproject commit 4274a6ac7a43a91d7296f6bbf2d1a2634a5ca443 Subproject commit 00a64caee5877d6cd23816776b8ed56c704f376e

@ -151,8 +151,6 @@ let return_param = "__return_param"
let self = "self" let self = "self"
let static = "static"
let std_addressof = QualifiedCppName.Match.of_fuzzy_qual_names ["std::addressof"] let std_addressof = QualifiedCppName.Match.of_fuzzy_qual_names ["std::addressof"]
let string_with_utf8_m = "stringWithUTF8String:" let string_with_utf8_m = "stringWithUTF8String:"

@ -148,8 +148,6 @@ val return_param : string
val self : string val self : string
val static : string
val std_addressof : QualifiedCppName.Match.quals_matcher val std_addressof : QualifiedCppName.Match.quals_matcher
val string_with_utf8_m : string val string_with_utf8_m : string

@ -70,14 +70,6 @@ let rec collect_list_tuples l (a, a1, b, c, d) =
collect_list_tuples l' (a @ a', a1 @ a1', b @ b', c @ c', d @ d') collect_list_tuples l' (a @ a', a1 @ a1', b @ b', c @ c', d @ d')
let is_static_var var_decl_info =
match var_decl_info.Clang_ast_t.vdi_storage_class with
| Some sc ->
String.equal sc CFrontend_config.static
| _ ->
false
let rec zip xs ys = let rec zip xs ys =
match (xs, ys) with [], _ | _, [] -> [] | x :: xs, y :: ys -> (x, y) :: zip xs ys match (xs, ys) with [], _ | _, [] -> [] | x :: xs, y :: ys -> (x, y) :: zip xs ys
@ -136,15 +128,15 @@ let mk_sil_global_var {CFrontend_config.source_file} ?(mk_name= fun _ x -> x) na
var_decl_info qt = var_decl_info qt =
let name_string, simple_name = get_var_name_mangled named_decl_info var_decl_info in let name_string, simple_name = get_var_name_mangled named_decl_info var_decl_info in
let translation_unit = let translation_unit =
match Clang_ast_t.((var_decl_info.vdi_storage_class, var_decl_info.vdi_init_expr)) with match Clang_ast_t.((var_decl_info.vdi_is_extern, var_decl_info.vdi_init_expr)) with
| Some "extern", None -> | true, None ->
(* some compilers simply disregard "extern" when the global is given some initialisation
code, which is why we make sure that [vdi_init_expr] is None here... *)
Pvar.TUExtern Pvar.TUExtern
| _, None when var_decl_info.Clang_ast_t.vdi_is_static_data_member -> | _, None when var_decl_info.Clang_ast_t.vdi_is_static_data_member ->
(* non-const static data member get extern scope unless they are defined out of line here (in which case vdi_init_expr will not be None) *) (* non-const static data member get extern scope unless they are defined out of line here (in which case vdi_init_expr will not be None) *)
Pvar.TUExtern Pvar.TUExtern
| _ -> | true, Some _
(* "extern" variables with initialisation code are not extern at all, but compilers accept this *)
| false, _ ->
Pvar.TUFile source_file Pvar.TUFile source_file
in in
let is_constexpr = var_decl_info.Clang_ast_t.vdi_is_const_expr in let is_constexpr = var_decl_info.Clang_ast_t.vdi_is_const_expr in

@ -26,8 +26,6 @@ val collect_list_tuples :
val swap_elements_list : 'a list -> 'a list val swap_elements_list : 'a list -> 'a list
val is_static_var : Clang_ast_t.var_decl_info -> bool
val zip : 'a list -> 'b list -> ('a * 'b) list val zip : 'a list -> 'b list -> ('a * 'b) list
val list_range : int -> int -> int list val list_range : int -> int -> int list

Loading…
Cancel
Save