Skip to content

Conversation

@davidstone
Copy link
Contributor

The mutable version of the overload is not used. The way we implemented code sharing in the const vs. mutable overloads had a const-correctness violation, anyway.

The mutable version of the overload is not used. The way we implemented code sharing in the const vs. mutable overloads had a const-correctness violation, anyway.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:analysis labels Dec 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 15, 2025

@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang

Author: David Stone (davidstone)

Changes

The mutable version of the overload is not used. The way we implemented code sharing in the const vs. mutable overloads had a const-correctness violation, anyway.


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

2 Files Affected:

  • (modified) clang/include/clang/Analysis/CFGStmtMap.h (+1-5)
  • (modified) clang/lib/Analysis/CFGStmtMap.cpp (+2-2)
diff --git a/clang/include/clang/Analysis/CFGStmtMap.h b/clang/include/clang/Analysis/CFGStmtMap.h
index 93cd9cfc5bdff..e5ad98d2f396b 100644
--- a/clang/include/clang/Analysis/CFGStmtMap.h
+++ b/clang/include/clang/Analysis/CFGStmtMap.h
@@ -40,11 +40,7 @@ class CFGStmtMap {
   /// are terminators, the CFGBlock is the block they appear as a terminator,
   /// and not the block they appear as a block-level expression (e.g, '&&').
   /// CaseStmts and LabelStmts map to the CFGBlock they label.
-  CFGBlock *getBlock(Stmt * S);
-
-  const CFGBlock *getBlock(const Stmt * S) const {
-    return const_cast<CFGStmtMap*>(this)->getBlock(const_cast<Stmt*>(S));
-  }
+  const CFGBlock *getBlock(const Stmt * S) const;
 };
 
 } // end clang namespace
diff --git a/clang/lib/Analysis/CFGStmtMap.cpp b/clang/lib/Analysis/CFGStmtMap.cpp
index 028e62ba89b79..a2b213e01cc14 100644
--- a/clang/lib/Analysis/CFGStmtMap.cpp
+++ b/clang/lib/Analysis/CFGStmtMap.cpp
@@ -24,9 +24,9 @@ static SMap *AsMap(void *m) { return (SMap*) m; }
 
 CFGStmtMap::~CFGStmtMap() { delete AsMap(M); }
 
-CFGBlock *CFGStmtMap::getBlock(Stmt *S) {
+const CFGBlock *CFGStmtMap::getBlock(const Stmt *S) const {
   SMap *SM = AsMap(M);
-  Stmt *X = S;
+  const Stmt *X = S;
 
   // If 'S' isn't in the map, walk the ParentMap to see if one of its ancestors
   // is in the map.

@github-actions
Copy link

github-actions bot commented Dec 15, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@davidstone davidstone merged commit ba05883 into main Dec 16, 2025
10 checks passed
@davidstone davidstone deleted the users/davidstone/remove-unused-CFGStmtMap-getBlock-overload branch December 16, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:analysis clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants