Author: Timm Bäder Date: 2023-10-15T08:52:43+02:00 New Revision: 3c4ecc4628601d07201780ea9ed23770a5a2d86c
URL: https://github.com/llvm/llvm-project/commit/3c4ecc4628601d07201780ea9ed23770a5a2d86c DIFF: https://github.com/llvm/llvm-project/commit/3c4ecc4628601d07201780ea9ed23770a5a2d86c.diff LOG: [clang][Interp][NFC] Refactor VisitImplicitValueInitExpr The FIXME comment here is not really correct. Also, handle the case of non-primitive array element types differently, to reduce indentation. 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 bda9cf1500804f7..e9e20b222d5d34f 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -504,19 +504,13 @@ bool ByteCodeExprGen<Emitter>::VisitImplicitValueInitExpr(const ImplicitValueIni assert(AT); const auto *CAT = cast<ConstantArrayType>(AT); size_t NumElems = CAT->getSize().getZExtValue(); + PrimType ElemT = classifyPrim(CAT->getElementType()); - if (std::optional<PrimType> ElemT = classify(CAT->getElementType())) { - // TODO(perf): For int and bool types, we can probably just skip this - // since we memset our Block*s to 0 and so we have the desired value - // without this. - for (size_t I = 0; I != NumElems; ++I) { - if (!this->visitZeroInitializer(*ElemT, CAT->getElementType(), E)) - return false; - if (!this->emitInitElem(*ElemT, I, E)) - return false; - } - } else { - assert(false && "default initializer for non-primitive type"); + for (size_t I = 0; I != NumElems; ++I) { + if (!this->visitZeroInitializer(ElemT, CAT->getElementType(), E)) + return false; + if (!this->emitInitElem(ElemT, I, E)) + return false; } return true; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits