Skip to content

Commit

Permalink
[clang] Use realpath in storing attributes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
skcho authored and facebook-github-bot committed Sep 4, 2024
1 parent e2d96a8 commit ccc2891
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions infer/src/clang/cFrontend_decl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
Expand Down

0 comments on commit ccc2891

Please sign in to comment.