aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-04-29 05:47:22 +0200
committerGitHub <noreply@github.com>2025-04-29 05:47:22 +0200
commit15579a8e72589b4fdf45c8f5bca52e58dcc9ce1d (patch)
treef81e705ab1e9083c8d901376cb78b03eec38ffff /clang/lib/AST/ByteCode/Compiler.cpp
parent7ce0f5a9cc37345fee801736bded83081b61571b (diff)
downloadllvm-15579a8e72589b4fdf45c8f5bca52e58dcc9ce1d.zip
llvm-15579a8e72589b4fdf45c8f5bca52e58dcc9ce1d.tar.gz
llvm-15579a8e72589b4fdf45c8f5bca52e58dcc9ce1d.tar.bz2
[clang][bytecode] Check array sizes against step limit (#137679)
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 9a1e61b..fe8d05c 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1862,6 +1862,13 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
if (Inits.size() == 1 && QT == Inits[0]->getType())
return this->delegate(Inits[0]);
+ const ConstantArrayType *CAT =
+ Ctx.getASTContext().getAsConstantArrayType(QT);
+ uint64_t NumElems = CAT->getZExtSize();
+
+ if (!this->emitCheckArraySize(NumElems, E))
+ return false;
+
unsigned ElementIndex = 0;
for (const Expr *Init : Inits) {
if (const auto *EmbedS =
@@ -1890,10 +1897,6 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
// Expand the filler expression.
// FIXME: This should go away.
if (ArrayFiller) {
- const ConstantArrayType *CAT =
- Ctx.getASTContext().getAsConstantArrayType(QT);
- uint64_t NumElems = CAT->getZExtSize();
-
for (; ElementIndex != NumElems; ++ElementIndex) {
if (!this->visitArrayElemInit(ElementIndex, ArrayFiller))
return false;