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

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 6 04:31:36 PST 2024


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

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. 

>From a06f149e584376aefd7b4f88e0b6db23963b367c Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Sat, 6 Jan 2024 07:26:06 -0500
Subject: [PATCH] [Clang][NFC] Fix out-of-bounds access

---
 clang/include/clang/Analysis/CFG.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 *>;



More information about the cfe-commits mailing list