[clang] [clang][Interp] Use array filler expression (PR #72865)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 20 05:09:38 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
This is obviously not what we should ideally do, but the current state is also broken. We are just leaving the other elements uninitialized and rely on them being zero-ed.
---
Full diff: https://github.com/llvm/llvm-project/pull/72865.diff
1 Files Affected:
- (modified) clang/lib/AST/Interp/ByteCodeExprGen.cpp (+14-1)
``````````diff
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 5dc1f9dfb10ff32..180749a75ebd22e 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -662,13 +662,26 @@ bool ByteCodeExprGen<Emitter>::VisitInitListExpr(const InitListExpr *E) {
return this->visitInitList(E->inits(), E);
if (T->isArrayType()) {
- // FIXME: Array fillers.
unsigned ElementIndex = 0;
for (const Expr *Init : E->inits()) {
if (!this->visitArrayElemInit(ElementIndex, Init))
return false;
++ElementIndex;
}
+
+ // Expand the filler expression.
+ // FIXME: This should go away.
+ if (const Expr *Filler = E->getArrayFiller()) {
+ const ConstantArrayType *CAT =
+ Ctx.getASTContext().getAsConstantArrayType(E->getType());
+ uint64_t NumElems = CAT->getSize().getZExtValue();
+
+ for (; ElementIndex != NumElems; ++ElementIndex) {
+ if (!this->visitArrayElemInit(ElementIndex, Filler))
+ return false;
+ }
+ }
+
return true;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/72865
More information about the cfe-commits
mailing list