Skip to content

Commit 3c4ecc4

Browse files
committed
[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.
1 parent 169f60f commit 3c4ecc4

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -504,19 +504,13 @@ bool ByteCodeExprGen<Emitter>::VisitImplicitValueInitExpr(const ImplicitValueIni
504504
assert(AT);
505505
const auto *CAT = cast<ConstantArrayType>(AT);
506506
size_t NumElems = CAT->getSize().getZExtValue();
507+
PrimType ElemT = classifyPrim(CAT->getElementType());
507508

508-
if (std::optional<PrimType> ElemT = classify(CAT->getElementType())) {
509-
// TODO(perf): For int and bool types, we can probably just skip this
510-
// since we memset our Block*s to 0 and so we have the desired value
511-
// without this.
512-
for (size_t I = 0; I != NumElems; ++I) {
513-
if (!this->visitZeroInitializer(*ElemT, CAT->getElementType(), E))
514-
return false;
515-
if (!this->emitInitElem(*ElemT, I, E))
516-
return false;
517-
}
518-
} else {
519-
assert(false && "default initializer for non-primitive type");
509+
for (size_t I = 0; I != NumElems; ++I) {
510+
if (!this->visitZeroInitializer(ElemT, CAT->getElementType(), E))
511+
return false;
512+
if (!this->emitInitElem(ElemT, I, E))
513+
return false;
520514
}
521515

522516
return true;

0 commit comments

Comments
 (0)