[all-commits] [llvm/llvm-project] b144b9: [clang][ssaf] Rework NestedBuildNamespaces of TU a...
Balázs Benics via All-commits
all-commits at lists.llvm.org
Sat Apr 18 06:58:18 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b144b9c483335d55c0678d177d0f58b5650e2802
https://github.com/llvm/llvm-project/commit/b144b9c483335d55c0678d177d0f58b5650e2802
Author: Balázs Benics <benicsbalazs at gmail.com>
Date: 2026-04-18 (Sat, 18 Apr 2026)
Changed paths:
M clang/include/clang/ScalableStaticAnalysisFramework/Core/EntityLinker/EntityLinker.h
M clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat.h
M clang/lib/ScalableStaticAnalysisFramework/Core/EntityLinker/EntityLinker.cpp
M clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/JSONFormatImpl.cpp
M clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/LUSummary.cpp
M clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/LUSummaryEncoding.cpp
M clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/TUSummary.cpp
M clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/TUSummaryEncoding.cpp
M clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/WPASuite.cpp
M clang/test/Analysis/Scalable/UnsafeBufferUsage/Inputs/tu-summary-bad-element.json
M clang/test/Analysis/Scalable/UnsafeBufferUsage/Inputs/tu-summary-bad-ptr-level.json
M clang/test/Analysis/Scalable/UnsafeBufferUsage/Inputs/tu-summary-no-key.json
M clang/test/Analysis/Scalable/UnsafeBufferUsage/Inputs/tu-summary.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/invalid-direct-callee-element.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/invalid-direct-callee-id.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/missing-def-col.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/missing-def-file.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/missing-def-line.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/missing-def.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/missing-direct-callees.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/missing-pretty-name.json
M clang/test/Analysis/Scalable/ssaf-format/Inputs/CallGraph/missing-virtual-callees.json
M clang/test/Analysis/Scalable/ssaf-linker/Inputs/tu-1.json
M clang/test/Analysis/Scalable/ssaf-linker/Inputs/tu-2.json
M clang/test/Analysis/Scalable/ssaf-linker/Inputs/tu-invalid-entity-id-multikey.json
M clang/test/Analysis/Scalable/ssaf-linker/Inputs/tu-invalid-entity-id-ref.json
M clang/test/Analysis/Scalable/ssaf-linker/Inputs/tu-invalid-entity-id-value.json
M clang/unittests/ScalableStaticAnalysisFramework/EntityLinkerTest.cpp
M clang/unittests/ScalableStaticAnalysisFramework/Serialization/JSONFormatTest/LUSummaryTest.cpp
M clang/unittests/ScalableStaticAnalysisFramework/Serialization/JSONFormatTest/TUSummaryTest.cpp
Log Message:
-----------
[clang][ssaf] Rework NestedBuildNamespaces of TU and LU summaries (#191489)
Problem:
ASTEntityMapping::getEntityName() creates EntityName with an empty
NestedBuildNamespace, but the linker expected the TU namespace to
already be present in the EntityName. This caused internal linkage
symbols to conflict during linking: since their NestedBuildNamespace was
empty, they all inherited the same LU namespace during resolution,
making internal symbols from different TUs appear identical. For
example, two "static inline" functions with the same USR in separate TUs
would be incorrectly merged into a single LU entity instead of remaining
distinct.
This is now fixed and demonstrated by the
InternalLinkageWithEmptyNamespaceAcrossTUs test, which creates two
internal linkage symbols across two TUs and verifies they remain
separate after linking.
---
TU summaries now omit the "namespace" field from entity names in JSON,
since the linker adds TU namespace qualification at link time. LU (and
WPA) summaries retain the "namespace" field as before, since their
entity names are fully resolved.
Split entityNameFromJSON/entityNameToJSON into TU and LU variants:
- tuEntityNameFromJSON: reads only "usr" and "suffix"
- tuEntityNameToJSON: writes only "usr" and "suffix"
- luEntityNameFromJSON/luEntityNameToJSON: full behavior with required
"namespace" field
Similarly split entityIdTableEntry and entityIdTable functions. Shared
helpers (entityNameCoreFromJSON, entityIdTableFromJSONImpl) to avoid
code duplication.
Update all TU JSON test inputs to remove the "namespace" field, and
update unit tests accordingly.
---
Alternatively, we could choose to populate the NestedBuildNamespace with
the TU namespace when creating an EntityName, thus meet the linker
expectation. However, this would bloat the representation, and also make
it redundant.
Assisted-By: claude
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list