[clang] [analyzer][NFC] Out-line PathSensitiveBugReport call-stack-hint bodies (PR #246958)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 02:52:56 PST 2026
https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/246958
- Move `PathSensitiveBugReport::markInvalid`, `addCallStackHint`, `hasCallStackHint` and `getCallStackMessage` bodies from `BugReporter.h` into `BugReporter.cpp`.
- They instantiated `llvm::SmallSet` and `std::map` member functions in every TU including the header, i.e. every checker.
Build-time impact (instructions retired, 196 `lib/StaticAnalyzer` TUs):
- Total: -0.81% (run-to-run noise ~0.23%).
- 161 TUs change by more than 0.15%, by -1.0% on average.
Assisted-by: Claude Code
>From f5963f97768687e52be1d517b233848bca4dd4a9 Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Sun, 29 Nov 2026 10:48:21 +0000
Subject: [PATCH] [analyzer][NFC] Out-line PathSensitiveBugReport
call-stack-hint bodies
- Move `PathSensitiveBugReport::markInvalid`, `addCallStackHint`,
`hasCallStackHint` and `getCallStackMessage` bodies from `BugReporter.h`
into `BugReporter.cpp`.
- They instantiated `llvm::SmallSet` and `std::map` member functions in every
TU including the header, i.e. every checker.
Build-time impact (instructions retired, 196 `lib/StaticAnalyzer` TUs):
- Total: -0.81% (run-to-run noise ~0.23%).
- 161 TUs change by more than 0.15%, by -1.0% on average.
Assisted-by: Claude Code
---
.../Core/BugReporter/BugReporter.h | 22 ++++-------------
clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 24 +++++++++++++++++++
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 528e57163b76a7..9d487607ba68d7 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -483,9 +483,7 @@ class PathSensitiveBugReport : public BugReport {
/// visitor decided to invalidate the bug report.
///
/// \sa removeInvalidation
- void markInvalid(const void *Tag, const void *Data) {
- Invalidations.insert(std::make_pair(Tag, Data));
- }
+ void markInvalid(const void *Tag, const void *Data);
/// Profile to identify equivalent bug reports for error report coalescing.
/// Reports are uniqued to ensure that we do not emit multiple diagnostics
@@ -522,24 +520,14 @@ class PathSensitiveBugReport : public BugReport {
}
void addCallStackHint(PathDiagnosticPieceRef Piece,
- std::unique_ptr<StackHintGenerator> StackHint) {
- StackHints[Piece] = std::move(StackHint);
- }
+ std::unique_ptr<StackHintGenerator> StackHint);
- bool hasCallStackHint(PathDiagnosticPieceRef Piece) const {
- return StackHints.count(Piece) > 0;
- }
+ bool hasCallStackHint(PathDiagnosticPieceRef Piece) const;
/// Produce the hint for the given node. The node contains
/// information about the call for which the diagnostic can be generated.
- std::string
- getCallStackMessage(PathDiagnosticPieceRef Piece,
- const ExplodedNode *N) const {
- auto I = StackHints.find(Piece);
- if (I != StackHints.end())
- return I->second->getMessage(N);
- return "";
- }
+ std::string getCallStackMessage(PathDiagnosticPieceRef Piece,
+ const ExplodedNode *N) const;
};
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index c0ade4e5f85708..7cdfdaf4cf09a1 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2176,6 +2176,30 @@ PathSensitiveBugReport::PathSensitiveBugReport(
"non-user facing!");
}
+void PathSensitiveBugReport::markInvalid(const void *Tag, const void *Data) {
+ Invalidations.insert(std::make_pair(Tag, Data));
+}
+
+void PathSensitiveBugReport::addCallStackHint(
+ PathDiagnosticPieceRef Piece,
+ std::unique_ptr<StackHintGenerator> StackHint) {
+ StackHints[Piece] = std::move(StackHint);
+}
+
+bool PathSensitiveBugReport::hasCallStackHint(
+ PathDiagnosticPieceRef Piece) const {
+ return StackHints.count(Piece) > 0;
+}
+
+std::string
+PathSensitiveBugReport::getCallStackMessage(PathDiagnosticPieceRef Piece,
+ const ExplodedNode *N) const {
+ auto I = StackHints.find(Piece);
+ if (I != StackHints.end())
+ return I->second->getMessage(N);
+ return "";
+}
+
void PathSensitiveBugReport::addVisitor(
std::unique_ptr<BugReporterVisitor> visitor) {
if (!visitor)
More information about the cfe-commits
mailing list