[clang] [Clang][NFC] Fix out-of-bounds access (PR #77193)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 6 04:32:02 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)

<details>
<summary>Changes</summary>

The changes to tablegen made by https://github.com/llvm/llvm-project/pull/76825 result in `StmtClass::lastStmtConstant` changing from `StmtClass::WhileStmtClass` to `StmtClass::GCCAsmStmtClass`. Since `CFG::BuildOptions::alwaysAdd` is never called with a `WhileStmt`, this has flown under the radar until now. 

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


1 Files Affected:

- (modified) clang/include/clang/Analysis/CFG.h (+1-1) 


``````````diff
diff --git a/clang/include/clang/Analysis/CFG.h b/clang/include/clang/Analysis/CFG.h
index 67383bb316d318..ec10768f600a2a 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -1215,7 +1215,7 @@ class CFG {
   //===--------------------------------------------------------------------===//
 
   class BuildOptions {
-    std::bitset<Stmt::lastStmtConstant> alwaysAddMask;
+    std::bitset<Stmt::lastStmtConstant + 1> alwaysAddMask;
 
   public:
     using ForcedBlkExprs = llvm::DenseMap<const Stmt *, const CFGBlock *>;

``````````

</details>


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


More information about the cfe-commits mailing list