[clang] Reapply "[clang][ssaf][NFC] Rework how the Force linker anchors are defined and used" (PR #194693)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 28 10:51:00 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-ssaf
Author: Balázs Benics (steakhal)
<details>
<summary>Changes</summary>
This reverts commit 582958c4337f539e650096c0257a322315298e1a.
Drop "const" from these anchor variables - like they are in clang-tidy
Turns out, MSVC likely doesn't conform with the C++ standard and makes
`const volatile` global variables have *internal* linkage - while they
should have *external* linkage.
https://eel.is/c++draft/basic.link#<!-- -->3.2
```
(3) The name of an entity that belongs to a namespace scope has internal linkage if it is the name of
(3.1) a variable, variable template, function, or function template that is explicitly declared static; or
(3.2) a non-template variable of non-volatile const-qualified type, unless
(3.2.1) it is declared in the purview of a module interface unit (outside the private-module-fragment, if any) or module partition, or
(3.2.2) it is explicitly declared extern, or
(3.2.3) it is inline, or
(3.2.4) it was previously declared and the prior declaration did not have internal linkage; or
```
Consequently, `const volatile` globals should NOT have *internal*
linkage, because `volatile` variables are exempt by (3.2).
---
Patch is 30.89 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/194693.diff
22 Files Affected:
- (modified) clang/docs/ScalableStaticAnalysisFramework/developer-docs/ForceLinkerHeaders.rst (+19-13)
- (modified) clang/docs/ScalableStaticAnalysisFramework/developer-docs/HowToExtend.rst (+17-10)
- (added) clang/include/clang/ScalableStaticAnalysisFramework/BuiltinAnchorSources.def (+26)
- (modified) clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormatRegistry.h (+4-6)
- (modified) clang/include/clang/ScalableStaticAnalysisFramework/Core/TUSummary/ExtractorRegistry.h (+4-6)
- (modified) clang/include/clang/ScalableStaticAnalysisFramework/Core/WholeProgramAnalysis/AnalysisRegistry.h (+7-7)
- (modified) clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h (+15-30)
- (modified) clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphExtractor.cpp (+2-2)
- (modified) clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphJSONFormat.cpp (+2-2)
- (modified) clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp (+5-3)
- (modified) clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp (+3-2)
- (modified) clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/JSONFormatImpl.cpp (+10-5)
- (modified) clang/lib/ScalableStaticAnalysisFramework/Core/WholeProgramAnalysis/AnalysisRegistry.cpp (+6-5)
- (modified) clang/unittests/ScalableStaticAnalysisFramework/Frontend/TUSummaryExtractorFrontendActionTest.cpp (-4)
- (modified) clang/unittests/ScalableStaticAnalysisFramework/Registries/FancyAnalysisData.cpp (-2)
- (modified) clang/unittests/ScalableStaticAnalysisFramework/Registries/MockSerializationFormat.cpp (-2)
- (modified) clang/unittests/ScalableStaticAnalysisFramework/Registries/MockSummaryExtractor1.cpp (-2)
- (modified) clang/unittests/ScalableStaticAnalysisFramework/Registries/MockSummaryExtractor2.cpp (-2)
- (removed) clang/unittests/ScalableStaticAnalysisFramework/SSAFBuiltinTestForceLinker.h (-51)
- (removed) clang/unittests/ScalableStaticAnalysisFramework/SSAFTestForceLinker.h (-23)
- (modified) clang/unittests/ScalableStaticAnalysisFramework/TestFixture.cpp (-1)
- (modified) clang/unittests/ScalableStaticAnalysisFramework/WholeProgramAnalysis/AnalysisDriverTest.cpp (-4)
``````````diff
diff --git a/clang/docs/ScalableStaticAnalysisFramework/developer-docs/ForceLinkerHeaders.rst b/clang/docs/ScalableStaticAnalysisFramework/developer-docs/ForceLinkerHeaders.rst
index c04b2b786308f..b273264382f81 100644
--- a/clang/docs/ScalableStaticAnalysisFramework/developer-docs/ForceLinkerHeaders.rst
+++ b/clang/docs/ScalableStaticAnalysisFramework/developer-docs/ForceLinkerHeaders.rst
@@ -37,22 +37,25 @@ Each registration translation unit defines a ``volatile int`` **anchor symbol**:
.. code-block:: c++
- // In MyExtractor.cpp — next to the registry Add<> object
+ // In MyExtractor.cpp - next to the registry Add<> object in the ``clang::ssaf`` namespace
// NOLINTNEXTLINE(misc-use-internal-linkage)
- volatile int SSAFMyExtractorAnchorSource = 0;
+ volatile int MyExtractorAnchorSource = 0;
-A **force-linker header** declares the symbol as ``extern`` and reads it into a
-``[[maybe_unused]] static int`` destination:
+For **in-tree** anchors, add a single ``ANCHOR(...)`` entry to
+``BuiltinAnchorSources.def`` (in alphabetical order):
.. code-block:: c++
- // In SSAFBuiltinForceLinker.h
- extern volatile int SSAFMyExtractorAnchorSource;
- [[maybe_unused]] static int SSAFMyExtractorAnchorDestination =
- SSAFMyExtractorAnchorSource;
+ // In clang/include/clang/ScalableStaticAnalysisFramework/BuiltinAnchorSources.def
+ ANCHOR(JSONFormatAnchorSource)
+ ANCHOR(MyExtractorAnchorSource) // <-- Add here, in alphabetical order
+
+``SSAFBuiltinForceLinker.h`` includes this ``.def`` file automatically to
+generate the ``extern`` declarations and the ``AnchorSources`` array — there is
+no need to edit that header directly.
Any translation unit that ``#include``\s this header now has a reference to
-``SSAFMyExtractorAnchorSource``, which forces the linker to pull in
+``MyExtractorAnchorSource``, which forces the linker to pull in
``MyExtractor.o`` — and with it, the static ``Add<>`` registration object.
The ``volatile`` qualifier is essential: without it the compiler could
@@ -85,11 +88,14 @@ point of a binary that uses ``clangScalableStaticAnalysisFrameworkCore``:
Naming convention
=================
-Anchor symbols follow the pattern ``SSAF<Component>AnchorSource`` and
-``SSAF<Component>AnchorDestination``. For example:
+Anchor symbols follow the pattern ``<Component>AnchorSource`` in the ``clang::ssaf`` namespace.
+For example:
+
+- ``JSONFormatAnchorSource``
+- ``MyExtractorAnchorSource``
-- ``SSAFJSONFormatAnchorSource`` / ``SSAFJSONFormatAnchorDestination``
-- ``SSAFMyExtractorAnchorSource`` / ``SSAFMyExtractorAnchorDestination``
+All anchor sources are aggregated into a single ``BuiltinAnchorDestination``
+lambda in the force-linker header (see ``SSAFBuiltinForceLinker.h``).
Considered alternatives
***********************
diff --git a/clang/docs/ScalableStaticAnalysisFramework/developer-docs/HowToExtend.rst b/clang/docs/ScalableStaticAnalysisFramework/developer-docs/HowToExtend.rst
index 7d92d7e6f2de7..41dbe6fcbac58 100644
--- a/clang/docs/ScalableStaticAnalysisFramework/developer-docs/HowToExtend.rst
+++ b/clang/docs/ScalableStaticAnalysisFramework/developer-docs/HowToExtend.rst
@@ -53,8 +53,10 @@ Step 2: Register the extractor
using namespace clang::ssaf;
+ namespace clang::ssaf {
// NOLINTNEXTLINE(misc-use-internal-linkage)
- volatile int SSAFMyExtractorAnchorSource = 0;
+ volatile int MyExtractorAnchorSource = 0;
+ } // namespace clang::ssaf
static TUSummaryExtractorRegistry::Add<MyExtractor>
RegisterExtractor("MyExtractor", "My awesome summary extractor");
@@ -65,16 +67,17 @@ Step 3: Add the force-linker anchor
===================================
See :doc:`ForceLinkerHeaders` for a full explanation of why this is needed.
-Add the following to the appropriate force-linker header:
+
+For **in-tree** additions, add one line to
+``clang/include/clang/ScalableStaticAnalysisFramework/BuiltinAnchorSources.def``
+(in alphabetical order):
.. code-block:: c++
- extern volatile int SSAFMyExtractorAnchorSource;
- [[maybe_unused]] static int SSAFMyExtractorAnchorDestination =
- SSAFMyExtractorAnchorSource;
+ ANCHOR(MyExtractorAnchorSource)
-For **in-tree** additions, add this to
-``clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h``.
+``SSAFBuiltinForceLinker.h`` includes this ``.def`` file automatically — no
+need to edit it directly.
For **downstream** additions, see `Out-of-tree (downstream) extensions`_ below.
@@ -125,8 +128,10 @@ Step 2: Register the format
using namespace clang::ssaf;
+ namespace clang::ssaf {
// NOLINTNEXTLINE(misc-use-internal-linkage)
- volatile int SSAFMyFormatAnchorSource = 0;
+ volatile int MyFormatAnchorSource = 0;
+ } // namespace clang::ssaf
static SerializationFormatRegistry::Add<MyFormat>
RegisterFormat("myformat", "My awesome serialization format");
@@ -161,7 +166,9 @@ For each analysis that should be serializable in your format, register a ``Forma
Step 4: Add the force-linker anchor
===================================
-Same pattern as for extractors — see `Adding a summary extractor`_ Step 3, and :doc:`ForceLinkerHeaders`.
+Same pattern as for extractors — add the anchor to ``BuiltinAnchorSources.def``
+(in alphabetical order). See `Adding a summary extractor`_ Step 3,
+and :doc:`ForceLinkerHeaders`.
Static extensibility
@@ -172,7 +179,7 @@ In-tree extensions
For extensions that are part of the upstream LLVM/Clang tree:
-#. Add the anchor to ``clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h``.
+#. Add the anchor to ``clang/include/clang/ScalableStaticAnalysisFramework/BuiltinAnchorSources.def`` (in alphabetical order).
#. Add the source files to the ``clangScalableStaticAnalysisFrameworkCore`` CMake library target.
#. That's it — the ``SSAFForceLinker.h`` umbrella includes ``SSAFBuiltinForceLinker.h``
transitively, so any binary that includes the umbrella will pull in the registration.
diff --git a/clang/include/clang/ScalableStaticAnalysisFramework/BuiltinAnchorSources.def b/clang/include/clang/ScalableStaticAnalysisFramework/BuiltinAnchorSources.def
new file mode 100644
index 0000000000000..63235f0630afc
--- /dev/null
+++ b/clang/include/clang/ScalableStaticAnalysisFramework/BuiltinAnchorSources.def
@@ -0,0 +1,26 @@
+//===- BuiltinAnchorSources.def ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file lists all the SSAF Anchor source names.
+/// This file should be exclusively used by SSAFBuiltinForceLinker.h
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef ANCHOR
+#define ANCHOR(NAME)
+#endif
+
+ANCHOR(AnalysisRegistryAnchorSource)
+ANCHOR(CallGraphExtractorAnchorSource)
+ANCHOR(CallGraphJSONFormatAnchorSource)
+ANCHOR(JSONFormatAnchorSource)
+ANCHOR(UnsafeBufferUsageExtractorAnchorSource)
+ANCHOR(UnsafeBufferUsageJSONFormatAnchorSource)
+
+#undef ANCHOR
diff --git a/clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormatRegistry.h b/clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormatRegistry.h
index a1955e64d5137..7b6a9d103f438 100644
--- a/clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormatRegistry.h
+++ b/clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormatRegistry.h
@@ -24,8 +24,10 @@
//
// Insert this code to the cpp file:
//
+// namespace clang::ssaf {
// // NOLINTNEXTLINE(misc-use-internal-linkage)
-// volatile int SSAFMyFormatAnchorSource = 0;
+// volatile int MyFormatAnchorSource = 0;
+// } // namespace clang::ssaf
// static SerializationFormatRegistry::Add<MyFormat>
// RegisterFormat("MyFormat", "My awesome serialization format");
// LLVM_INSTANTIATE_REGISTRY(llvm::Registry<MyFormat::FormatInfo>)
@@ -50,15 +52,11 @@
// "The MyFormat format info implementation for MyAnalysis"
// );
//
-// Finally, insert a use of the new anchor symbol into the force-linker header:
+// Finally, extend the `AnchorSources` list in the force-linker header:
// clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h:
//
// This anchor is used to force the linker to link the MyFormat registration.
//
-// extern volatile int SSAFMyFormatAnchorSource;
-// [[maybe_unused]] static int SSAFMyFormatAnchorDestination =
-// SSAFMyFormatAnchorSource;
-//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_SERIALIZATION_SERIALIZATIONFORMATREGISTRY_H
diff --git a/clang/include/clang/ScalableStaticAnalysisFramework/Core/TUSummary/ExtractorRegistry.h b/clang/include/clang/ScalableStaticAnalysisFramework/Core/TUSummary/ExtractorRegistry.h
index da57838c64b2f..5db6541ed46e6 100644
--- a/clang/include/clang/ScalableStaticAnalysisFramework/Core/TUSummary/ExtractorRegistry.h
+++ b/clang/include/clang/ScalableStaticAnalysisFramework/Core/TUSummary/ExtractorRegistry.h
@@ -9,18 +9,16 @@
// Registry for TUSummaryExtractors, and some helper functions.
// To register some custom extractor, insert this code:
//
+// namespace clang::ssaf {
// // NOLINTNEXTLINE(misc-use-internal-linkage)
-// volatile int SSAFMyExtractorAnchorSource = 0;
+// volatile int MyExtractorAnchorSource = 0;
+// } // namespace clang::ssaf
// static TUSummaryExtractorRegistry::Add<MyExtractor>
// X("MyExtractor", "My awesome extractor");
//
-// Finally, insert a use of the new anchor symbol into the force-linker header:
+// Finally, extend the `AnchorSources` list in the force-linker header:
// clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h:
//
-// extern volatile int SSAFMyExtractorAnchorSource;
-// [[maybe_unused]] static int SSAFMyExtractorAnchorDestination =
-// SSAFMyExtractorAnchorSource;
-//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_TUSUMMARY_EXTRACTORREGISTRY_H
diff --git a/clang/include/clang/ScalableStaticAnalysisFramework/Core/WholeProgramAnalysis/AnalysisRegistry.h b/clang/include/clang/ScalableStaticAnalysisFramework/Core/WholeProgramAnalysis/AnalysisRegistry.h
index 44eabce6c809c..39375f5f4b750 100644
--- a/clang/include/clang/ScalableStaticAnalysisFramework/Core/WholeProgramAnalysis/AnalysisRegistry.h
+++ b/clang/include/clang/ScalableStaticAnalysisFramework/Core/WholeProgramAnalysis/AnalysisRegistry.h
@@ -9,19 +9,19 @@
// Unified registry for both SummaryAnalysis and DerivedAnalysis subclasses.
//
// To register an analysis, add a static Add<AnalysisT> and an anchor source
-// in its translation unit, then add the matching anchor destination to the
-// relevant force-linker header:
+// in its translation unit, then add the anchor source to the `AnchorSources`
+// list in the relevant force-linker header:
//
// // MyAnalysis.cpp
// static AnalysisRegistry::Add<MyAnalysis>
// Registered("One-line description of MyAnalysis");
//
-// volatile int SSAFMyAnalysisAnchorSource = 0;
+// namespace clang::ssaf {
+// // NOLINTNEXTLINE(misc-use-internal-linkage)
+// volatile int MyAnalysisAnchorSource = 0;
+// } // namespace clang::ssaf
//
-// // SSAFBuiltinForceLinker.h (or the relevant force-linker header)
-// extern volatile int SSAFMyAnalysisAnchorSource;
-// [[maybe_unused]] static int SSAFMyAnalysisAnchorDestination =
-// SSAFMyAnalysisAnchorSource;
+// // Extend SSAFBuiltinForceLinker.h (or the relevant force-linker header)
//
// The registry entry name is derived automatically from
// MyAnalysis::analysisName(), so name-mismatch bugs are impossible.
diff --git a/clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h b/clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h
index 5616976e10f77..354379645a8de 100644
--- a/clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h
+++ b/clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h
@@ -20,39 +20,24 @@
#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SSAFBUILTINFORCELINKER_H
#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SSAFBUILTINFORCELINKER_H
-// TODO: Move these to the `clang::ssaf` namespace.
+namespace clang::ssaf {
-// This anchor is used to force the linker to link the JSONFormat registration.
-extern volatile int SSAFJSONFormatAnchorSource;
-[[maybe_unused]] static int SSAFJSONFormatAnchorDestination =
- SSAFJSONFormatAnchorSource;
+#define ANCHOR(NAME) extern volatile int NAME;
+#include "BuiltinAnchorSources.def"
-// This anchor is used to force the linker to link the AnalysisRegistry.
-extern volatile int SSAFAnalysisRegistryAnchorSource;
-[[maybe_unused]] static int SSAFAnalysisRegistryAnchorDestination =
- SSAFAnalysisRegistryAnchorSource;
+// Force the linker to link in the built-in SSAF registrations.
+[[maybe_unused]] static const int BuiltinAnchorDestination = [] {
+ int AnchorSources[]{
+#define ANCHOR(NAME) NAME,
+#include "BuiltinAnchorSources.def"
+ };
-// This anchor is used to force the linker to link the UnsafeBufferUsage
-// JSON format.
-extern volatile int UnsafeBufferUsageSSAFJSONFormatAnchorSource;
-[[maybe_unused]] static int UnsafeBufferUsageSSAFJSONFormatAnchorDestination =
- UnsafeBufferUsageSSAFJSONFormatAnchorSource;
+ int SomeUse = 0;
+ for (int V : AnchorSources)
+ SomeUse |= V;
+ return SomeUse;
+}();
-// This anchor is used to force the linker to link the
-// UnsafeBufferUsageTUSummaryExtractor.
-extern volatile int UnsafeBufferUsageTUSummaryExtractorAnchorSource;
-[[maybe_unused]] static int
- UnsafeBufferUsageTUSummaryExtractorAnchorDestination =
- UnsafeBufferUsageTUSummaryExtractorAnchorSource;
-
-// This anchor is used to force the linker to link the CallGraphExtractor.
-extern volatile int CallGraphExtractorAnchorSource;
-[[maybe_unused]] static int CallGraphExtractorAnchorDestination =
- CallGraphExtractorAnchorSource;
-
-// This anchor is used to force the linker to link the CallGraph JSON format.
-extern volatile int CallGraphJSONFormatAnchorSource;
-[[maybe_unused]] static int CallGraphJSONFormatAnchorDestination =
- CallGraphJSONFormatAnchorSource;
+} // namespace clang::ssaf
#endif // LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SSAFBUILTINFORCELINKER_H
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphExtractor.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphExtractor.cpp
index 1dbed7e0b0d8a..25163f307a1a1 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphExtractor.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphExtractor.cpp
@@ -101,7 +101,7 @@ static TUSummaryExtractorRegistry::Add<CallGraphExtractor>
RegisterExtractor(CallGraphSummary::Name,
"Extracts static call-graph information");
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the CallGraphExtractor.
+namespace clang::ssaf {
// NOLINTNEXTLINE(misc-use-internal-linkage)
volatile int CallGraphExtractorAnchorSource = 0;
+} // namespace clang::ssaf
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphJSONFormat.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphJSONFormat.cpp
index 860e26417eb55..6f2414280bfaa 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphJSONFormat.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/CallGraph/CallGraphJSONFormat.cpp
@@ -168,7 +168,7 @@ static llvm::Registry<JSONFormat::FormatInfo>::Add<CallGraphJSONFormatInfo>
RegisterFormatInfo(CallGraphSummary::Name,
"JSON Format info for CallGraph summary");
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the JSON format for CallGraphSummary.
+namespace clang::ssaf {
// NOLINTNEXTLINE(misc-use-internal-linkage)
volatile int CallGraphJSONFormatAnchorSource = 0;
+} // namespace clang::ssaf
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp
index ea5d2297b9836..660376b4a8e91 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp
@@ -84,9 +84,6 @@ static llvm::Registry<JSONFormat::FormatInfo>::Add<
UnsafeBufferUsageEntitySummary::Name,
"JSON Format info for UnsafeBufferUsageEntitySummary");
-// NOLINTNEXTLINE(misc-use-internal-linkage)
-volatile int UnsafeBufferUsageSSAFJSONFormatAnchorSource = 0;
-
// For unit test:
llvm::Expected<std::unique_ptr<EntitySummary>>
ssaf::serializeDeserializeRoundTrip(
@@ -108,3 +105,8 @@ ssaf::serializeDeserializeRoundTrip(
return deserializeImpl(serialize(S, IdToJson), IdFromJson);
}
+
+namespace clang::ssaf {
+// NOLINTNEXTLINE(misc-use-internal-linkage)
+volatile int UnsafeBufferUsageJSONFormatAnchorSource = 0;
+} // namespace clang::ssaf
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
index 550416c353fb7..b1eaa338574cc 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
@@ -98,9 +98,10 @@ void clang::ssaf::UnsafeBufferUsageTUSummaryExtractor::HandleTranslationUnit(
assert(InsertionSucceeded && "duplicated contributor extraction");
}
}
-
+namespace clang::ssaf {
// NOLINTNEXTLINE(misc-use-internal-linkage)
-volatile int UnsafeBufferUsageTUSummaryExtractorAnchorSource = 0;
+volatile int UnsafeBufferUsageExtractorAnchorSource = 0;
+} // namespace clang::ssaf
static clang::ssaf::TUSummaryExtractorRegistry::Add<
ssaf::UnsafeBufferUsageTUSummaryExtractor>
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/JSONFormatImpl.cpp b/clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/JSONFormatImpl.cpp
index 8db7480e683f5..e3f7c9983f759 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/JSONFormatImpl.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat/JSONFormatImpl.cpp
@@ -11,17 +11,22 @@
#include "clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormatRegistry.h"
#include "llvm/Support/Registry.h"
-// NOLINTNEXTLINE(misc-use-internal-linkage)
-volatile int SSAFJSONFormatAnchorSource = 0;
-LLVM_INSTANTIATE_REGISTRY(llvm::Registry<clang::ssaf::JSONFormat::FormatInfo>)
+using namespace clang;
+using namespace ssaf;
+
LLVM_INSTANTIATE_REGISTRY(
- llvm::Registry<clang::ssaf::JSONFormat::AnalysisResultRegistry::Codec>)
+ llvm::Registry<JSONFormat::AnalysisResultRegistry::Codec>)
+
+LLVM_INSTANTIATE_REGISTRY(llvm::Registry<JSONFormat::FormatInfo>)
-static clang::ssaf::SerializationFormatRegistry::Add<clang::ssaf::JSONFormat>
+static SerializationFormatRegistry::Add<JSONFormat>
RegisterJSONFormat("json", "JSON serialization format");
namespace clang::ssaf {
+// NOLINTNEXTLINE(misc-use-internal-linkage)
+volatile int JSONFormatAnchorSource = 0;
+
//----------------------------------------------------------------------------
// JSON Reader and Writer
//----------------------------------------------------------------------------
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Core/WholeProgramAnalysis/AnalysisRegistry.cpp b/clang/lib/ScalableStaticAnalysisFramework/Core/WholeProgramAnalysis/AnalysisRegistry.cpp
index 8e1ea954d9afd..288e94a2dc5e9 10...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/194693
More information about the cfe-commits
mailing list