diff options
author | Vincent <llvm@viceroygroup.ca> | 2025-08-25 15:06:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-25 21:06:49 +0200 |
commit | fefdb494bfb881047343fdcad95547205a9d60ff (patch) | |
tree | 0cb0553ffc718f07715aa71b39d29d36951de340 /clang/lib/AST/ByteCode/Compiler.cpp | |
parent | 5886a276ed24c2cd936e602441365bb0bbe5ef40 (diff) | |
download | llvm-fefdb494bfb881047343fdcad95547205a9d60ff.zip llvm-fefdb494bfb881047343fdcad95547205a9d60ff.tar.gz llvm-fefdb494bfb881047343fdcad95547205a9d60ff.tar.bz2 |
[Clang] Fix Variable Length Array `_Countof` Crash (#154627)
Check for missing VLA size expressions (e.g. in int a[*][10]) before
evaluation to avoid crashes in _Countof and constant expression checks.
Fixes #152826
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Compiler.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index c36cb64..e61d5e08 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -2248,7 +2248,9 @@ bool Compiler<Emitter>::VisitUnaryExprOrTypeTraitExpr( assert(VAT); if (VAT->getElementType()->isArrayType()) { std::optional<APSInt> Res = - VAT->getSizeExpr()->getIntegerConstantExpr(ASTCtx); + VAT->getSizeExpr() + ? VAT->getSizeExpr()->getIntegerConstantExpr(ASTCtx) + : std::nullopt; if (Res) { if (DiscardResult) return true; |