Skip to content

Commit 5b49bf6

Browse files
committed
[clang][bytecode] Emit embed element casts directly
The element initializer is known to be an IntegerLiteral, the previous signature of the lambda just didn't specify that. So we can also do the cast directly instead of doing it via a Cast op.
1 parent 2c40fd6 commit 5b49bf6

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,15 +1932,10 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
19321932
dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts())) {
19331933
PrimType TargetT = classifyPrim(Init->getType());
19341934

1935-
auto Eval = [&](const Expr *Init, unsigned ElemIndex) {
1936-
PrimType InitT = classifyPrim(Init->getType());
1937-
if (!this->visit(Init))
1935+
auto Eval = [&](const IntegerLiteral *IL, unsigned ElemIndex) {
1936+
if (!this->emitConst(IL->getValue(), Init))
19381937
return false;
1939-
if (InitT != TargetT) {
1940-
if (!this->emitCast(InitT, TargetT, E))
1941-
return false;
1942-
}
1943-
return this->emitInitElem(TargetT, ElemIndex, Init);
1938+
return this->emitInitElem(TargetT, ElemIndex, IL);
19441939
};
19451940
if (!EmbedS->doForEachDataElement(Eval, ElementIndex))
19461941
return false;

0 commit comments

Comments
 (0)