https://github.com/davidstone updated
https://github.com/llvm/llvm-project/pull/172364
>From 478f00364b3d5b924dab1ed8dc07faa4d14e1249 Mon Sep 17 00:00:00 2001
From: David Stone
Date: Tue, 2 Dec 2025 15:32:46 -0700
Subject: [PATCH 1/2] [clang][NFC] In `CFGStmtMap`, remove mutable `getBlock`
overload.
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.
---
clang/include/clang/Analysis/CFGStmtMap.h | 6 +-
clang/lib/Analysis/CFGStmtMap.cpp | 4 ++--
2 files changed, 3 insertions(+), 7 deletions(-)
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(this)->getBlock(const_cast(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.
>From 5216a8bd6e6823df6a02f397ff5fe21a1cf82f2b Mon Sep 17 00:00:00 2001
From: David Stone
Date: Mon, 15 Dec 2025 13:54:56 -0700
Subject: [PATCH 2/2] format
---
clang/include/clang/Analysis/CFGStmtMap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/Analysis/CFGStmtMap.h
b/clang/include/clang/Analysis/CFGStmtMap.h
index e5ad98d2f396b..842059daf7560 100644
--- a/clang/include/clang/Analysis/CFGStmtMap.h
+++ b/clang/include/clang/Analysis/CFGStmtMap.h
@@ -40,7 +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.
- const CFGBlock *getBlock(const Stmt * S) const;
+ const CFGBlock *getBlock(const Stmt *S) const;
};
} // end clang namespace
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits