[llvm-branch-commits] [clang] [NFC][SSAF] Extract common code in Analyses to a shared file (PR #191932)
Ziqing Luo via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Apr 20 22:04:01 PDT 2026
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/191932
>From 9407fc4e97ff188dff2c76ba7bcc12fbe6dbf194 Mon Sep 17 00:00:00 2001
From: Ziqing Luo <ziqing_luo at apple.com>
Date: Mon, 13 Apr 2026 17:45:15 -0700
Subject: [PATCH 1/5] [NFC][SSAF] Extract common code in Analyses to a shared
file
Created SSAFAnalysesCommon.h for the SSAF analyses implementation.
---
.../EntityPointerLevelFormat.h | 12 -----
.../EntityPointerLevel/EntityPointerLevel.cpp | 30 +++--------
.../Analyses/SSAFAnalysesCommon.h | 50 +++++++++++++++++++
.../UnsafeBufferUsage/UnsafeBufferUsage.cpp | 1 +
.../UnsafeBufferUsageExtractor.cpp | 12 +----
5 files changed, 59 insertions(+), 46 deletions(-)
create mode 100644 clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
diff --git a/clang/include/clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevelFormat.h b/clang/include/clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevelFormat.h
index 4e7a9eff32d5c..7b125edb1fb7f 100644
--- a/clang/include/clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevelFormat.h
+++ b/clang/include/clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevelFormat.h
@@ -12,18 +12,6 @@
#include "clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.h"
#include "clang/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat.h"
-namespace {
-template <typename... Ts>
-llvm::Error makeSawButExpectedError(const llvm::json::Value &Saw,
- llvm::StringRef Expected,
- const Ts &...ExpectedArgs) {
- std::string Fmt = ("saw %s but expected " + Expected).str();
- std::string SawStr = llvm::formatv("{0:2}", Saw).str();
-
- return llvm::createStringError(Fmt.c_str(), SawStr.c_str(), ExpectedArgs...);
-}
-} // namespace
-
namespace clang::ssaf {
llvm::json::Value
entityPointerLevelToJSON(const EntityPointerLevel &EPL,
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
index 7e4200467ce9e..69bec9b19dae4 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.h"
+#include "SSAFAnalysesCommon.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/StmtVisitor.h"
@@ -18,25 +19,6 @@
using namespace clang;
using namespace ssaf;
-namespace {
-template <typename DeclOrExpr> bool hasPtrOrArrType(const DeclOrExpr *E) {
- return llvm::isa<PointerType, ArrayType>(E->getType().getCanonicalType());
-}
-
-template <typename NodeTy, typename... Ts>
-llvm::Error makeErrAtNode(ASTContext &Ctx, const NodeTy &N, StringRef Fmt,
- const Ts &...Args) {
- std::string LocStr = N.getBeginLoc().printToString(Ctx.getSourceManager());
- return llvm::createStringError((Fmt + " at %s").str().c_str(), Args...,
- LocStr.c_str());
-}
-
-llvm::Error makeEntityNameErr(ASTContext &Ctx, const NamedDecl &D) {
- return makeErrAtNode(Ctx, D, "failed to create entity name for %s",
- D.getNameAsString().data());
-}
-} // namespace
-
namespace clang::ssaf {
// Translate a pointer type expression 'E' to a (set of) EntityPointerLevel(s)
// associated with the declared type of the base address of `E`. If the base
@@ -64,7 +46,7 @@ class EntityPointerLevelTranslator
// Fallback method for all unsupported expression kind:
llvm::Error fallback(const Stmt *E) {
- return makeErrAtNode(Ctx, *E,
+ return makeErrAtNode(Ctx, E,
"attempt to translate %s to EntityPointerLevels",
E->getStmtClassName());
}
@@ -98,7 +80,7 @@ class EntityPointerLevelTranslator
Expected<EntityPointerLevel> translate(const NamedDecl *D, bool IsRet) {
if (IsRet && !isa<FunctionDecl>(D))
return makeErrAtNode(
- Ctx, *D,
+ Ctx, D,
"attempt to call getEntityNameForReturn on a NamedDecl of %s kind",
D->getDeclKindName());
@@ -107,7 +89,7 @@ class EntityPointerLevelTranslator
: getEntityName(D);
if (EN)
return createEntityPointerLevelFor(*EN);
- return makeEntityNameErr(Ctx, *D);
+ return makeEntityNameErr(Ctx, D);
}
static EntityPointerLevel incrementPointerLevel(const EntityPointerLevel &E) {
@@ -230,14 +212,14 @@ class EntityPointerLevelTranslator
Expected<EntityPointerLevelSet> VisitDeclRefExpr(const DeclRefExpr *E) {
if (auto EntityName = getEntityName(E->getDecl()))
return EntityPointerLevelSet{createEntityPointerLevelFor(*EntityName)};
- return makeEntityNameErr(Ctx, *E->getDecl());
+ return makeEntityNameErr(Ctx, E->getDecl());
}
// Translate({., ->}f) -> {(MemberDecl, 1)}
Expected<EntityPointerLevelSet> VisitMemberExpr(const MemberExpr *E) {
if (auto EntityName = getEntityName(E->getMemberDecl()))
return EntityPointerLevelSet{createEntityPointerLevelFor(*EntityName)};
- return makeEntityNameErr(Ctx, *E->getMemberDecl());
+ return makeEntityNameErr(Ctx, E->getMemberDecl());
}
Expected<EntityPointerLevelSet>
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
new file mode 100644
index 0000000000000..c14e2a98751d2
--- /dev/null
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
@@ -0,0 +1,50 @@
+//===- SSAFAnalysesCommon.h -------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Common code in SSAF analyses implementations
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_SSAFANALYSESCOMMON_H
+#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_SSAFANALYSESCOMMON_H
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/JSON.h"
+
+using namespace clang;
+
+template <typename NodeTy, typename... Ts>
+llvm::Error makeErrAtNode(ASTContext &Ctx, const NodeTy *N, StringRef Fmt,
+ const Ts &...Args) {
+ std::string LocStr = N->getBeginLoc().printToString(Ctx.getSourceManager());
+ return llvm::createStringError((Fmt + " at %s").str().c_str(), Args...,
+ LocStr.c_str());
+}
+
+template <typename... Ts>
+llvm::Error makeSawButExpectedError(const llvm::json::Value &Saw,
+ llvm::StringRef Expected,
+ const Ts &...ExpectedArgs) {
+ std::string Fmt = ("saw %s but expected " + Expected).str();
+ std::string SawStr = llvm::formatv("{0:2}", Saw).str();
+
+ return llvm::createStringError(Fmt.c_str(), SawStr.c_str(), ExpectedArgs...);
+}
+
+template <typename DeclOrExpr> bool hasPtrOrArrType(const DeclOrExpr *E) {
+ return llvm::isa<PointerType, ArrayType>(E->getType().getCanonicalType());
+}
+
+inline llvm::Error makeEntityNameErr(ASTContext &Ctx, const NamedDecl *D) {
+ return makeErrAtNode(Ctx, D, "failed to create entity name for %s",
+ D->getNameAsString().data());
+}
+
+#endif // LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_SSAFANALYSESCOMMON_H
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp
index 47e03476d1063..ea5d2297b9836 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "clang/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.h"
+#include "SSAFAnalysesCommon.h"
#include "clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.h"
#include "clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevelFormat.h"
#include "clang/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageTest.h"
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
index 72944bd0be323..f79bc5c8574d6 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "SSAFAnalysesCommon.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DynamicRecursiveASTVisitor.h"
@@ -26,15 +27,6 @@ namespace {
using namespace clang;
using namespace ssaf;
-llvm::Error makeCreateEntityNameError(const NamedDecl *FailedDecl,
- ASTContext &Ctx) {
- std::string LocStr = FailedDecl->getSourceRange().getBegin().printToString(
- Ctx.getSourceManager());
- return llvm::createStringError(
- "failed to create entity name for %s declared at %s",
- FailedDecl->getNameAsString().c_str(), LocStr.c_str());
-}
-
Expected<EntityPointerLevelSet>
buildEntityPointerLevels(std::set<const Expr *> &&UnsafePointers,
ASTContext &Ctx,
@@ -140,7 +132,7 @@ class clang::ssaf::UnsafeBufferUsageTUSummaryExtractor
auto ContributorName = getEntityName(CD);
if (!ContributorName)
- llvm::reportFatalInternalError(makeCreateEntityNameError(CD, Ctx));
+ llvm::reportFatalInternalError(makeEntityNameErr(Ctx, CD));
auto [Ignored, InsertionSucceeded] = SummaryBuilder.addSummary(
addEntity(*ContributorName), std::move(*EntitySummary));
>From 21b98e0e8a504087a4c8185ac7653084c56b51db Mon Sep 17 00:00:00 2001
From: Ziqing Luo <ziqing_luo at apple.com>
Date: Wed, 15 Apr 2026 11:37:39 -0700
Subject: [PATCH 2/5] clean up
---
.../EntityPointerLevel/EntityPointerLevel.h | 2 +-
.../EntityPointerLevel/EntityPointerLevel.cpp | 10 +++++-----
.../Analyses/SSAFAnalysesCommon.h | 15 ++++++---------
.../UnsafeBufferUsageExtractor.cpp | 2 --
4 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/clang/include/clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.h b/clang/include/clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.h
index ed8400f65e310..506b81170f757 100644
--- a/clang/include/clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.h
+++ b/clang/include/clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.h
@@ -107,7 +107,7 @@ EntityPointerLevel buildEntityPointerLevel(EntityId, unsigned);
/// \param IsFunRet true iff the created EPL is associated with the return type
/// of a function entity.
llvm::Expected<EntityPointerLevel>
-creatEntityPointerLevel(const NamedDecl *ND,
+createEntityPointerLevel(const NamedDecl *ND,
llvm::function_ref<EntityId(EntityName EN)> AddEntity,
bool IsFunRet = false);
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
index 69bec9b19dae4..68a452ee61b43 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
@@ -68,12 +68,12 @@ class EntityPointerLevelTranslator
return EntityPointerLevelSet{Incremented.begin(), Incremented.end()};
}
- std::function<EntityId(EntityName EN)> AddEntity;
+ llvm::function_ref<EntityId(EntityName EN)> AddEntity;
ASTContext &Ctx;
public:
- EntityPointerLevelTranslator(std::function<EntityId(EntityName EN)> AddEntity,
- ASTContext &Ctx)
+ EntityPointerLevelTranslator(
+ llvm::function_ref<EntityId(EntityName EN)> AddEntity, ASTContext &Ctx)
: AddEntity(AddEntity), Ctx(Ctx) {}
Expected<EntityPointerLevelSet> translate(const Expr *E) { return Visit(E); }
@@ -156,7 +156,7 @@ class EntityPointerLevelTranslator
}
}
- // Translate((T*)base) -> Translate(p) if p has pointer type
+ // Translate((T*)base) -> Translate(base) if base has pointer type
// -> {} otherwise
Expected<EntityPointerLevelSet> VisitCastExpr(const CastExpr *E) {
if (hasPtrOrArrType(E->getSubExpr()))
@@ -238,7 +238,7 @@ Expected<EntityPointerLevelSet> clang::ssaf::translateEntityPointerLevel(
}
/// Create an EntityPointerLevel from a ValueDecl of a pointer type.
-Expected<EntityPointerLevel> clang::ssaf::creatEntityPointerLevel(
+Expected<EntityPointerLevel> clang::ssaf::createEntityPointerLevel(
const NamedDecl *ND, llvm::function_ref<EntityId(EntityName EN)> AddEntity,
bool IsFunRet) {
EntityPointerLevelTranslator Translator(AddEntity, ND->getASTContext());
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
index c14e2a98751d2..bce1129891df0 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
@@ -13,16 +13,11 @@
#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_SSAFANALYSESCOMMON_H
#include "clang/AST/Decl.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/DynamicRecursiveASTVisitor.h"
-#include "llvm/ADT/Twine.h"
#include "llvm/Support/JSON.h"
-using namespace clang;
-
template <typename NodeTy, typename... Ts>
-llvm::Error makeErrAtNode(ASTContext &Ctx, const NodeTy *N, StringRef Fmt,
- const Ts &...Args) {
+llvm::Error makeErrAtNode(clang::ASTContext &Ctx, const NodeTy *N,
+ llvm::StringRef Fmt, const Ts &...Args) {
std::string LocStr = N->getBeginLoc().printToString(Ctx.getSourceManager());
return llvm::createStringError((Fmt + " at %s").str().c_str(), Args...,
LocStr.c_str());
@@ -39,10 +34,12 @@ llvm::Error makeSawButExpectedError(const llvm::json::Value &Saw,
}
template <typename DeclOrExpr> bool hasPtrOrArrType(const DeclOrExpr *E) {
- return llvm::isa<PointerType, ArrayType>(E->getType().getCanonicalType());
+ return llvm::isa<clang::PointerType, clang::ArrayType>(
+ E->getType().getCanonicalType());
}
-inline llvm::Error makeEntityNameErr(ASTContext &Ctx, const NamedDecl *D) {
+inline llvm::Error makeEntityNameErr(clang::ASTContext &Ctx,
+ const clang::NamedDecl *D) {
return makeErrAtNode(Ctx, D, "failed to create entity name for %s",
D->getNameAsString().data());
}
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
index f79bc5c8574d6..df313aa8a5c25 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
@@ -117,8 +117,6 @@ class clang::ssaf::UnsafeBufferUsageTUSummaryExtractor
}
} ContributorFinder;
- ContributorFinder.VisitTranslationUnitDecl(Ctx.getTranslationUnitDecl());
-
ContributorFinder.TraverseAST(Ctx);
for (auto *CD : ContributorFinder.Contributors) {
auto EntitySummary = extractEntitySummary(CD, Ctx);
>From 25ccdfabba513cad38e5687fb122e1d85cd15982 Mon Sep 17 00:00:00 2001
From: Ziqing Luo <ziqing_luo at apple.com>
Date: Wed, 15 Apr 2026 12:35:38 -0700
Subject: [PATCH 3/5] fix build issue
---
.../Analyses/SSAFAnalysesCommon.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
index bce1129891df0..22274de5e471f 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
@@ -12,6 +12,7 @@
#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_SSAFANALYSESCOMMON_H
#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_SSAFANALYSESCOMMON_H
+#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "llvm/Support/JSON.h"
>From cd5634a0dfce86ea186e15b0e939a491d4bacd0c Mon Sep 17 00:00:00 2001
From: Ziqing Luo <ziqing_luo at apple.com>
Date: Mon, 20 Apr 2026 18:33:28 -0700
Subject: [PATCH 4/5] Move templates into clang::ssaf
---
.../Analyses/CMakeLists.txt | 1 +
.../Analyses/SSAFAnalysesCommon.cpp | 17 +++++++++++++++++
.../Analyses/SSAFAnalysesCommon.h | 9 ++++-----
3 files changed, 22 insertions(+), 5 deletions(-)
create mode 100644 clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.cpp
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/CMakeLists.txt b/clang/lib/ScalableStaticAnalysisFramework/Analyses/CMakeLists.txt
index c15ff3b3c42e7..12a334260cda7 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/CMakeLists.txt
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/CMakeLists.txt
@@ -6,6 +6,7 @@ add_clang_library(clangScalableStaticAnalysisFrameworkAnalyses
CallGraph/CallGraphExtractor.cpp
CallGraph/CallGraphJSONFormat.cpp
EntityPointerLevel/EntityPointerLevel.cpp
+ SSAFAnalysesCommon.cpp
UnsafeBufferUsage/UnsafeBufferUsage.cpp
UnsafeBufferUsage/UnsafeBufferUsageExtractor.cpp
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.cpp
new file mode 100644
index 0000000000000..481c545edc32a
--- /dev/null
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.cpp
@@ -0,0 +1,17 @@
+//===- SSAFAnalysesCommon.cpp ---------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "SSAFAnalysesCommon.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+
+llvm::Error clang::ssaf::makeEntityNameErr(clang::ASTContext &Ctx,
+ const clang::NamedDecl *D) {
+ return makeErrAtNode(Ctx, D, "failed to create entity name for %s",
+ D->getNameAsString().data());
+}
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
index 22274de5e471f..4ae37ebdac765 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/SSAFAnalysesCommon.h
@@ -16,6 +16,7 @@
#include "clang/AST/Decl.h"
#include "llvm/Support/JSON.h"
+namespace clang::ssaf {
template <typename NodeTy, typename... Ts>
llvm::Error makeErrAtNode(clang::ASTContext &Ctx, const NodeTy *N,
llvm::StringRef Fmt, const Ts &...Args) {
@@ -39,10 +40,8 @@ template <typename DeclOrExpr> bool hasPtrOrArrType(const DeclOrExpr *E) {
E->getType().getCanonicalType());
}
-inline llvm::Error makeEntityNameErr(clang::ASTContext &Ctx,
- const clang::NamedDecl *D) {
- return makeErrAtNode(Ctx, D, "failed to create entity name for %s",
- D->getNameAsString().data());
-}
+llvm::Error makeEntityNameErr(clang::ASTContext &Ctx,
+ const clang::NamedDecl *D);
+} // namespace clang::ssaf
#endif // LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_SSAFANALYSESCOMMON_H
>From a69a290e3fc6888991fd1474aef1836021bfac58 Mon Sep 17 00:00:00 2001
From: Ziqing Luo <ziqing_luo at apple.com>
Date: Mon, 20 Apr 2026 21:36:33 -0700
Subject: [PATCH 5/5] a class should own a std::function instead of a
llvm::function_ref
---
.../Analyses/EntityPointerLevel/EntityPointerLevel.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp b/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
index 68a452ee61b43..52e6705ec43af 100644
--- a/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
+++ b/clang/lib/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.cpp
@@ -68,12 +68,12 @@ class EntityPointerLevelTranslator
return EntityPointerLevelSet{Incremented.begin(), Incremented.end()};
}
- llvm::function_ref<EntityId(EntityName EN)> AddEntity;
+ std::function<EntityId(EntityName EN)> AddEntity;
ASTContext &Ctx;
public:
- EntityPointerLevelTranslator(
- llvm::function_ref<EntityId(EntityName EN)> AddEntity, ASTContext &Ctx)
+ EntityPointerLevelTranslator(std::function<EntityId(EntityName EN)> AddEntity,
+ ASTContext &Ctx)
: AddEntity(AddEntity), Ctx(Ctx) {}
Expected<EntityPointerLevelSet> translate(const Expr *E) { return Visit(E); }
More information about the llvm-branch-commits
mailing list