From ed55fc63f2d27c986a6aad284280faeec9ce1989 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Fri, 3 Nov 2017 10:38:23 -0700 Subject: [PATCH] [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 --- facebook-clang-plugins | 2 +- infer/src/clang/cFrontend_config.ml | 2 -- infer/src/clang/cFrontend_config.mli | 2 -- infer/src/clang/cGeneral_utils.ml | 18 +++++------------- infer/src/clang/cGeneral_utils.mli | 2 -- 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/facebook-clang-plugins b/facebook-clang-plugins index 4274a6ac7..00a64caee 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit 4274a6ac7a43a91d7296f6bbf2d1a2634a5ca443 +Subproject commit 00a64caee5877d6cd23816776b8ed56c704f376e diff --git a/infer/src/clang/cFrontend_config.ml b/infer/src/clang/cFrontend_config.ml index b6bfe1546..f7f08d94b 100644 --- a/infer/src/clang/cFrontend_config.ml +++ b/infer/src/clang/cFrontend_config.ml @@ -151,8 +151,6 @@ let return_param = "__return_param" let self = "self" -let static = "static" - let std_addressof = QualifiedCppName.Match.of_fuzzy_qual_names ["std::addressof"] let string_with_utf8_m = "stringWithUTF8String:" diff --git a/infer/src/clang/cFrontend_config.mli b/infer/src/clang/cFrontend_config.mli index 7a0fe3885..423faede6 100644 --- a/infer/src/clang/cFrontend_config.mli +++ b/infer/src/clang/cFrontend_config.mli @@ -148,8 +148,6 @@ val return_param : string val self : string -val static : string - val std_addressof : QualifiedCppName.Match.quals_matcher val string_with_utf8_m : string diff --git a/infer/src/clang/cGeneral_utils.ml b/infer/src/clang/cGeneral_utils.ml index 5570f1987..6b34f3cee 100644 --- a/infer/src/clang/cGeneral_utils.ml +++ b/infer/src/clang/cGeneral_utils.ml @@ -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') -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 = 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 = let name_string, simple_name = get_var_name_mangled named_decl_info var_decl_info in let translation_unit = - match Clang_ast_t.((var_decl_info.vdi_storage_class, var_decl_info.vdi_init_expr)) with - | Some "extern", 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... *) + match Clang_ast_t.((var_decl_info.vdi_is_extern, var_decl_info.vdi_init_expr)) with + | true, None -> Pvar.TUExtern | _, 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) *) Pvar.TUExtern - | _ -> + | true, Some _ + (* "extern" variables with initialisation code are not extern at all, but compilers accept this *) + | false, _ -> Pvar.TUFile source_file in let is_constexpr = var_decl_info.Clang_ast_t.vdi_is_const_expr in diff --git a/infer/src/clang/cGeneral_utils.mli b/infer/src/clang/cGeneral_utils.mli index dce413599..98e4e6400 100644 --- a/infer/src/clang/cGeneral_utils.mli +++ b/infer/src/clang/cGeneral_utils.mli @@ -26,8 +26,6 @@ val collect_list_tuples : 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 list_range : int -> int -> int list