tbaederr wrote:
I came up with this quick fix:
```diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp
b/clang/lib/AST/ByteCode/Compiler.cpp
index 55abd51659b4..03df770b8b33 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -265,7 +265,7 @@ template <class Emitter> class InitStackScope final {
public:
InitStackScope(Compiler<Emitter> *Ctx, bool Active)
: Ctx(Ctx), OldValue(Ctx->InitStackActive), Active(Active) {
- Ctx->InitStackActive = Active;
+ Ctx->InitStackActive = Active || OldValue;
if (Active)
Ctx->InitStack.push_back(InitLink::DIE());
}
@@ -2308,24 +2308,46 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const
Expr *> Inits,
return this->emitInvalid(E);
}
+
// Handle discarding first.
- if (DiscardResult) {
- for (const Expr *Init : Inits) {
- if (!this->discard(Init))
- return false;
- }
- return true;
- }
+ // if (DiscardResult) {
+ // for (const Expr *Init : Inits) {
+ // if (!this->discard(Init))
+ // return false;
+ // }
+ // return true;
+ // }
// Primitive values.
if (OptPrimType T = classify(QT)) {
- assert(!DiscardResult);
+ if (DiscardResult) {
+ for (const Expr *Init : Inits) {
+ if (!this->discard(Init))
+ return false;
+ }
+ return true;
+ }
if (Inits.size() == 0)
return this->visitZeroInitializer(*T, QT, E);
assert(Inits.size() == 1);
return this->delegate(Inits[0]);
}
+ assert(!canClassify(E->getType()));
+
+ UnsignedOrNone LocalIndex = std::nullopt;
+ if (DiscardResult && !Initializing) {
+ LocalIndex = allocateLocal(E);
+ if (!LocalIndex)
+ return false;
+ if (!this->emitGetPtrLocal(*LocalIndex, E))
+ return false;
+
+ // Should rarely happen, but just enter this function again.
+ InitLinkScope<Emitter> ILS2(this, InitLink::Temp(*LocalIndex));
+ return this->visitInitializerPop(E);
+
+ }
if (QT->isRecordType()) {
const Record *R = getRecord(QT);
```
https://github.com/llvm/llvm-project/pull/219952
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits