llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Balázs Benics (steakhal)

<details>
<summary>Changes</summary>

- 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

---
Full diff: https://github.com/llvm/llvm-project/pull/246958.diff


2 Files Affected:

- (modified) clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(+5-17) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporter.cpp (+24) 


``````````diff
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)

``````````

</details>


https://github.com/llvm/llvm-project/pull/246958
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to