Author: Timm Bäder Date: 2024-06-25T17:50:53+02:00 New Revision: b7768c5485844306cd3c8afeef609ddf9d79696a
URL: https://github.com/llvm/llvm-project/commit/b7768c5485844306cd3c8afeef609ddf9d79696a DIFF: https://github.com/llvm/llvm-project/commit/b7768c5485844306cd3c8afeef609ddf9d79696a.diff LOG: [clang][Interp][NFC] Use delegate() to delegate to only initlist item Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 69661a590b9c2..7b5aaa02a22c5 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1234,7 +1234,7 @@ bool ByteCodeExprGen<Emitter>::visitInitList(ArrayRef<const Expr *> Inits, const Record *R = getRecord(E->getType()); if (Inits.size() == 1 && E->getType() == Inits[0]->getType()) - return this->visitInitializer(Inits[0]); + return this->delegate(Inits[0]); auto initPrimitiveField = [=](const Record::Field *FieldToInit, const Expr *Init, PrimType T) -> bool { @@ -1329,22 +1329,8 @@ bool ByteCodeExprGen<Emitter>::visitInitList(ArrayRef<const Expr *> Inits, } if (T->isArrayType()) { - // Prepare composite return value. - if (!Initializing) { - if (GlobalDecl) { - std::optional<unsigned> GlobalIndex = P.createGlobal(E); - if (!GlobalIndex) - return false; - if (!this->emitGetPtrGlobal(*GlobalIndex, E)) - return false; - } else { - std::optional<unsigned> LocalIndex = allocateLocal(E); - if (!LocalIndex) - return false; - if (!this->emitGetPtrLocal(*LocalIndex, E)) - return false; - } - } + if (Inits.size() == 1 && E->getType() == Inits[0]->getType()) + return this->delegate(Inits[0]); unsigned ElementIndex = 0; for (const Expr *Init : Inits) { @@ -2150,7 +2136,7 @@ bool ByteCodeExprGen<Emitter>::VisitMaterializeTemporaryExpr( if (Initializing) { // We already have a value, just initialize that. - return this->visitInitializer(SubExpr); + return this->delegate(SubExpr); } // If we don't end up using the materialized temporary anyway, don't // bother creating it. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits