From ccc28916c9f7a7dd9e1d6dee922347588f194a29 Mon Sep 17 00:00:00 2001 From: Sungkeun Cho Date: Wed, 4 Sep 2024 01:15:18 -0700 Subject: [PATCH] [clang] Use realpath in storing attributes Summary: This diff uses realpaths when checking whether a class is used in the source file or not, i.e. resolving symbolic links. Reviewed By: ngorogiannis Differential Revision: D62136756 Privacy Context Container: L1208441 fbshipit-source-id: f0d37c9218c23c510a7e4332ba9525335485987c --- infer/src/clang/cFrontend_decl.ml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 49de9ba61b4..3745f7882c7 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -399,8 +399,8 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron false - let is_used_in_file (sl_file_class : Clang_ast_t.source_file option) ctx_source_file = - Option.exists sl_file_class ~f:(String.equal ctx_source_file) + let is_used_in_file (sl_file_class : Clang_ast_t.source_file) ctx_source_file = + String.equal (Utils.realpath sl_file_class) ctx_source_file let rec store_attributes tenv trans_unit_ctx dec = @@ -414,10 +414,11 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron let parent_ptr = Option.value_exn decl_info.Clang_ast_t.di_parent_pointer in let class_decl = CAst_utils.get_decl parent_ptr in let ctx_source_file = - trans_unit_ctx.CFrontend_config.source_file |> SourceFile.to_abs_path + trans_unit_ctx.CFrontend_config.source_file |> SourceFile.to_abs_path |> Utils.realpath in match class_decl with - | Some (ClassTemplateSpecializationDecl (_, _, _, _, _, _, _, _, _, {sl_file}, _)) + | Some + (ClassTemplateSpecializationDecl (_, _, _, _, _, _, _, _, _, {sl_file= Some sl_file}, _)) when Config.cxx && is_used_in_file sl_file ctx_source_file -> let ms = let procname = CType_decl.CProcname.from_decl ~tenv dec in