[clang] f5145f4 - [Clang][NFC] Fix out-of-bounds access (#77193)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 8 15:21:19 PST 2024
Author: Krystian Stasiowski
Date: 2024-01-08T18:21:16-05:00
New Revision: f5145f4dc819d73ff8bebcfba3779533b150884e
URL: https://github.com/llvm/llvm-project/commit/f5145f4dc819d73ff8bebcfba3779533b150884e
DIFF: https://github.com/llvm/llvm-project/commit/f5145f4dc819d73ff8bebcfba3779533b150884e.diff
LOG: [Clang][NFC] Fix out-of-bounds access (#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.
Once such test in which an out-of-bounds access occurs is
`test/Sema/inline-asm-validate.c`, among many others.
Added:
Modified:
clang/include/clang/Analysis/CFG.h
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/CFG.h b/clang/include/clang/Analysis/CFG.h
index 67383bb316d318..9f776ca6cc260d 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -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 *>;
More information about the cfe-commits
mailing list