llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

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

Author: David Stone (davidstone)

<details>
<summary>Changes</summary>



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


7 Files Affected:

- (modified) clang/include/clang/Analysis/AnalysisDeclContext.h (+1-1) 
- (modified) clang/include/clang/Analysis/CFGStmtMap.h (+5-5) 
- (modified) clang/lib/Analysis/AnalysisDeclContext.cpp (+2-2) 
- (modified) clang/lib/Analysis/CFGStmtMap.cpp (+5-6) 
- (modified) clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp (+2-1) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (+1-1) 
- (modified) clang/lib/StaticAnalyzer/Core/CallEvent.cpp (+1-1) 


``````````diff
diff --git a/clang/include/clang/Analysis/AnalysisDeclContext.h 
b/clang/include/clang/Analysis/AnalysisDeclContext.h
index ced4bb8595bea..76fb96bacc377 100644
--- a/clang/include/clang/Analysis/AnalysisDeclContext.h
+++ b/clang/include/clang/Analysis/AnalysisDeclContext.h
@@ -151,7 +151,7 @@ class AnalysisDeclContext {
 
   CFG *getCFG();
 
-  CFGStmtMap *getCFGStmtMap();
+  const CFGStmtMap *getCFGStmtMap();
 
   CFGReverseBlockReachabilityAnalysis *getCFGReachablityAnalysis();
 
diff --git a/clang/include/clang/Analysis/CFGStmtMap.h 
b/clang/include/clang/Analysis/CFGStmtMap.h
index 2a997df20c5eb..cde24b9f2b282 100644
--- a/clang/include/clang/Analysis/CFGStmtMap.h
+++ b/clang/include/clang/Analysis/CFGStmtMap.h
@@ -23,18 +23,18 @@ class ParentMap;
 class Stmt;
 
 class CFGStmtMap {
-  using SMap = llvm::DenseMap<const Stmt *, CFGBlock *>;
-  ParentMap *PM;
+  using SMap = llvm::DenseMap<const Stmt *, const CFGBlock *>;
+  const ParentMap *PM;
   SMap M;
 
-  CFGStmtMap(ParentMap *pm, SMap m) : PM(pm), M(std::move(m)) {}
+  CFGStmtMap(const ParentMap *pm, SMap m) : PM(pm), M(std::move(m)) {}
 
-  static void Accumulate(SMap &SM, CFGBlock *B);
+  static void Accumulate(SMap &SM, const CFGBlock *B);
 
 public:
   /// Returns a new CFGMap for the given CFG.  It is the caller's
   /// responsibility to 'delete' this object when done using it.
-  static CFGStmtMap *Build(CFG* C, ParentMap *PM);
+  static CFGStmtMap *Build(const CFG *C, const ParentMap *PM);
 
   /// Returns the CFGBlock the specified Stmt* appears in.  For Stmt* that
   /// are terminators, the CFGBlock is the block they appear as a terminator,
diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp 
b/clang/lib/Analysis/AnalysisDeclContext.cpp
index f188fc6921ed1..f683b9efc1d1e 100644
--- a/clang/lib/Analysis/AnalysisDeclContext.cpp
+++ b/clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -250,11 +250,11 @@ CFG *AnalysisDeclContext::getUnoptimizedCFG() {
   return completeCFG.get();
 }
 
-CFGStmtMap *AnalysisDeclContext::getCFGStmtMap() {
+const CFGStmtMap *AnalysisDeclContext::getCFGStmtMap() {
   if (cfgStmtMap)
     return cfgStmtMap.get();
 
-  if (CFG *c = getCFG()) {
+  if (const CFG *c = getCFG()) {
     cfgStmtMap.reset(CFGStmtMap::Build(c, &getParentMap()));
     return cfgStmtMap.get();
   }
diff --git a/clang/lib/Analysis/CFGStmtMap.cpp 
b/clang/lib/Analysis/CFGStmtMap.cpp
index a8de07c0ce10a..eb42c8663526f 100644
--- a/clang/lib/Analysis/CFGStmtMap.cpp
+++ b/clang/lib/Analysis/CFGStmtMap.cpp
@@ -34,7 +34,7 @@ const CFGBlock *CFGStmtMap::getBlock(const Stmt *S) const {
   return nullptr;
 }
 
-void CFGStmtMap::Accumulate(SMap &SM, CFGBlock *B) {
+void CFGStmtMap::Accumulate(SMap &SM, const CFGBlock *B) {
   // First walk the block-level expressions.
   for (const CFGElement &CE : *B) {
     if (std::optional<CFGStmt> CS = CE.getAs<CFGStmt>()) {
@@ -43,17 +43,17 @@ void CFGStmtMap::Accumulate(SMap &SM, CFGBlock *B) {
   }
 
   // Look at the label of the block.
-  if (Stmt *Label = B->getLabel())
+  if (const Stmt *Label = B->getLabel())
     SM[Label] = B;
 
   // Finally, look at the terminator.  If the terminator was already added
   // because it is a block-level expression in another block, overwrite
   // that mapping.
-  if (Stmt *Term = B->getTerminatorStmt())
+  if (const Stmt *Term = B->getTerminatorStmt())
     SM[Term] = B;
 }
 
-CFGStmtMap *CFGStmtMap::Build(CFG *C, ParentMap *PM) {
+CFGStmtMap *CFGStmtMap::Build(const CFG *C, const ParentMap *PM) {
   if (!C || !PM)
     return nullptr;
 
@@ -61,9 +61,8 @@ CFGStmtMap *CFGStmtMap::Build(CFG *C, ParentMap *PM) {
 
   // Walk all blocks, accumulating the block-level expressions, labels,
   // and terminators.
-  for (CFGBlock *BB : *C)
+  for (const CFGBlock *BB : *C)
     Accumulate(SM, BB);
 
   return new CFGStmtMap(PM, std::move(SM));
 }
-
diff --git a/clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
index 309e3d250de06..49b20fc877188 100644
--- a/clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
@@ -162,7 +162,8 @@ class AnalysisOrderChecker
         return;
 
       llvm::errs() << "CFGElement: ";
-      CFGStmtMap *Map = C.getCurrentAnalysisDeclContext()->getCFGStmtMap();
+      const CFGStmtMap *Map =
+          C.getCurrentAnalysisDeclContext()->getCFGStmtMap();
       CFGElement LastElement = Map->getBlock(S)->back();
 
       if (LastElement.getAs<CFGStmt>())
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 0ba3c05d2d163..7df5fab0843ac 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1906,7 +1906,7 @@ SuppressInlineDefensiveChecksVisitor::VisitNode(const 
ExplodedNode *Succ,
       if (!CurStmt->getBeginLoc().isMacroID())
         return nullptr;
 
-      CFGStmtMap *Map = CurLC->getAnalysisDeclContext()->getCFGStmtMap();
+      const CFGStmtMap *Map = CurLC->getAnalysisDeclContext()->getCFGStmtMap();
       CurTerminatorStmt = Map->getBlock(CurStmt)->getTerminatorStmt();
     } else {
       return nullptr;
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp 
b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index d04c827ce1391..3c0e2641e65fe 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -174,7 +174,7 @@ CallEvent::getCalleeStackFrame(unsigned BlockCount) const {
   // instead of doing this reverse lookup, we would be able to build the stack
   // frame for non-expression-based calls, and also we wouldn't need the 
reverse
   // lookup.
-  CFGStmtMap *Map = LCtx->getAnalysisDeclContext()->getCFGStmtMap();
+  const CFGStmtMap *Map = LCtx->getAnalysisDeclContext()->getCFGStmtMap();
   const CFGBlock *B = Map->getBlock(E);
   assert(B);
 

``````````

</details>


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

Reply via email to