Skip to content

Commit f5145f4

Browse files
authored
[Clang][NFC] Fix out-of-bounds access (#77193)
The changes to tablegen made by #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. Once such test in which an out-of-bounds access occurs is `test/Sema/inline-asm-validate.c`, among many others.
1 parent 6eab9dd commit f5145f4

File tree

1 file changed

+3
-1
lines changed
  • clang/include/clang/Analysis

1 file changed

+3
-1
lines changed

clang/include/clang/Analysis/CFG.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,9 @@ class CFG {
12151215
//===--------------------------------------------------------------------===//
12161216

12171217
class BuildOptions {
1218-
std::bitset<Stmt::lastStmtConstant> alwaysAddMask;
1218+
// Stmt::lastStmtConstant has the same value as the last Stmt kind,
1219+
// so make sure we add one to account for this!
1220+
std::bitset<Stmt::lastStmtConstant + 1> alwaysAddMask;
12191221

12201222
public:
12211223
using ForcedBlkExprs = llvm::DenseMap<const Stmt *, const CFGBlock *>;

0 commit comments

Comments
 (0)