[llvm-branch-commits] [clang] [analyzer][NFC] BugReporterVisitors.h should include MemRegion.h (PR #235283)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Oct 24 04:59:50 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balázs Benics (steakhal)

<details>
<summary>Changes</summary>

BugReporterVisitors.h includes RangedConstraintManager.h but uses
nothing it declares: RangeSet, Range, ConstraintMap and
SimpleConstraintManager appear nowhere in the file. What the header
actually needs is MemRegion.h, which supplies SubRegion,
MemRegionManager and MemRegion completeness for an inline constructor;
today those arrive only by accident, transitively through
RangedConstraintManager.h -> ProgramState.h. Swapping the include for
the one that carries the used declarations makes the dependency honest
and adds a forward declaration of CallEvent in namespace clang::ento
for the one name that only needs to be incomplete.

One header needs a compensating include: Z3CrosscheckVisitor.h uses
ConstraintMap and was getting RangedConstraintManager.h through
BugReporterVisitors.h, so it now includes it directly. No translation
unit in clangStaticAnalyzerCore, clangStaticAnalyzerCheckers or
clangStaticAnalyzerFrontend required any other change.

This patch doesn't improve compile time but improves include hygiene.

Authored-By: Claude

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


2 Files Affected:

- (modified) clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h (+2-1) 
- (modified) clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h (+1) 


``````````diff
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index 18d299f8bf7e2..9b1da8ce5e828 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -16,7 +16,7 @@
 
 #include "clang/Analysis/ProgramPoint.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -40,6 +40,7 @@ namespace ento {
 
 class PathSensitiveBugReport;
 class BugReporterContext;
+class CallEvent;
 class ExplodedNode;
 class MemRegion;
 class PathDiagnosticPiece;
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h
index 952ee09902dde..60e00a7535dbf 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/Z3CrosscheckVisitor.h
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_Z3CROSSCHECKVISITOR_H
 
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 
 namespace clang::ento {
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/235283


More information about the llvm-branch-commits mailing list