Skip to content

Commit

Permalink
[Clang][NFC] Fix out-of-bounds access (#77193)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sdkrystian committed Jan 8, 2024
1 parent 6eab9dd commit f5145f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clang/include/clang/Analysis/CFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,9 @@ class CFG {
//===--------------------------------------------------------------------===//

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

public:
using ForcedBlkExprs = llvm::DenseMap<const Stmt *, const CFGBlock *>;
Expand Down

0 comments on commit f5145f4

Please sign in to comment.