Skip to content

Commit bb92c80

Browse files
authored
[clang][bytecode][NFC] Simplify VisitCompoundLiteralExpr (#140547)
1 parent dc25ab3 commit bb92c80

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,32 +2922,22 @@ bool Compiler<Emitter>::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
29222922
if (T && !E->isLValue()) {
29232923
// For primitive types, we just visit the initializer.
29242924
return this->delegate(Init);
2925-
} else {
2926-
unsigned LocalIndex;
2927-
2928-
if (T)
2929-
LocalIndex = this->allocateLocalPrimitive(Init, *T, /*IsConst=*/false);
2930-
else if (std::optional<unsigned> MaybeIndex = this->allocateLocal(Init))
2931-
LocalIndex = *MaybeIndex;
2932-
else
2933-
return false;
2925+
}
29342926

2935-
if (!this->emitGetPtrLocal(LocalIndex, E))
2936-
return false;
2927+
unsigned LocalIndex;
2928+
if (T)
2929+
LocalIndex = this->allocateLocalPrimitive(Init, *T, /*IsConst=*/false);
2930+
else if (std::optional<unsigned> MaybeIndex = this->allocateLocal(Init))
2931+
LocalIndex = *MaybeIndex;
2932+
else
2933+
return false;
29372934

2938-
if (T) {
2939-
if (!this->visit(Init)) {
2940-
return false;
2941-
}
2942-
return this->emitInit(*T, E);
2943-
} else {
2944-
if (!this->visitInitializer(Init) || !this->emitFinishInit(E))
2945-
return false;
2946-
}
2947-
return true;
2948-
}
2935+
if (!this->emitGetPtrLocal(LocalIndex, E))
2936+
return false;
29492937

2950-
return false;
2938+
if (T)
2939+
return this->visit(Init) && this->emitInit(*T, E);
2940+
return this->visitInitializer(Init) && this->emitFinishInit(E);
29512941
}
29522942

29532943
template <class Emitter>

0 commit comments

Comments
 (0)