From 0904be07aae8acfade1dc5600d096cfed8dcdf83 Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Tue, 3 Sep 2019 08:26:00 -0700 Subject: [PATCH] [clang] Upgrade Infer after change to the plugin to swap storage_class with is_static Summary: We currently use storage_class only for checking is_static, adding the flag instead in the plugin to improve perf by avoiding string comparisons. update-submodule: facebook-clang-plugins Reviewed By: ngorogiannis Differential Revision: D17156173 fbshipit-source-id: 2b84a0b84 --- facebook-clang-plugins | 2 +- infer/src/clang/CType_decl.ml | 32 +++++++++++++++---------------- infer/src/clang/cGeneral_utils.ml | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/facebook-clang-plugins b/facebook-clang-plugins index 80f122707..eeff8d14a 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit 80f1227070a8e284ad05664bd3d9b959f0b63573 +Subproject commit eeff8d14a8d98d5c157ebaf84cb320866ffaf1f0 diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index bdad6a1ac..93e20e0d2 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -542,23 +542,21 @@ and get_template_info tenv (fdi : Clang_ast_t.function_decl_info) = and mk_c_function ?tenv name function_decl_info_opt parameters = let file = match function_decl_info_opt with - | Some (decl_info, function_decl_info) -> ( - match function_decl_info.Clang_ast_t.fdi_storage_class with - | Some "static" - (* when we model static functions, we cannot take the file into account to - create a mangled name because the file of the model is different to the real file, - thus the model won't work *) - when not (CTrans_models.is_modelled_static_function (QualifiedCppName.to_qual_string name)) - -> - let file_opt = - (fst decl_info.Clang_ast_t.di_source_range).Clang_ast_t.sl_file - |> Option.map ~f:SourceFile.from_abs_path - in - let file_to_hex src = SourceFile.to_string src |> Utils.string_crc_hex32 in - Option.value_map ~f:file_to_hex ~default:"" file_opt - | _ -> - "" ) - | None -> + (* when we model static functions, we cannot take the file into account to + create a mangled name because the file of the model is different to the real file, + thus the model won't work *) + | Some (decl_info, function_decl_info) + when function_decl_info.Clang_ast_t.fdi_is_static + && not + (CTrans_models.is_modelled_static_function (QualifiedCppName.to_qual_string name)) + -> + let file_opt = + (fst decl_info.Clang_ast_t.di_source_range).Clang_ast_t.sl_file + |> Option.map ~f:SourceFile.from_abs_path + in + let file_to_hex src = SourceFile.to_string src |> Utils.string_crc_hex32 in + Option.value_map ~f:file_to_hex ~default:"" file_opt + | _ -> "" in let mangled_opt, is_cpp = diff --git a/infer/src/clang/cGeneral_utils.ml b/infer/src/clang/cGeneral_utils.ml index 30599ebc6..b907b0ecf 100644 --- a/infer/src/clang/cGeneral_utils.ml +++ b/infer/src/clang/cGeneral_utils.ml @@ -141,7 +141,7 @@ let mk_sil_global_var {CFrontend_config.source_file} ?(mk_name = fun _ x -> x) d var_decl_info.Clang_ast_t.vdi_is_global (* only top level declarations are really have file scope, static field members have a global scope *) && (not var_decl_info.Clang_ast_t.vdi_is_static_data_member) - && match var_decl_info.Clang_ast_t.vdi_storage_class with Some "static" -> true | _ -> false + && var_decl_info.Clang_ast_t.vdi_is_static in Pvar.mk_global ~is_constexpr ~is_ice ~is_pod ~is_static_local:var_decl_info.Clang_ast_t.vdi_is_static_local ~is_static_global