aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-08-10 19:02:08 +0200
committerGitHub <noreply@github.com>2025-08-10 19:02:08 +0200
commit2b4b721faf852a405b25064c0d3b59a2372efe2b (patch)
tree68d5b65572eb29f16e3d12d8dce47366f622ad1f
parentb08e86cb7f7368531c4c12502dc1bed78f3e19a1 (diff)
downloadllvm-2b4b721faf852a405b25064c0d3b59a2372efe2b.zip
llvm-2b4b721faf852a405b25064c0d3b59a2372efe2b.tar.gz
llvm-2b4b721faf852a405b25064c0d3b59a2372efe2b.tar.bz2
[clang][bytecode] Emit embed element casts directly (#152928)
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.
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 5275b86..8e651cf 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1932,15 +1932,10 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts())) {
PrimType TargetT = classifyPrim(Init->getType());
- auto Eval = [&](const Expr *Init, unsigned ElemIndex) {
- PrimType InitT = classifyPrim(Init->getType());
- if (!this->visit(Init))
+ auto Eval = [&](const IntegerLiteral *IL, unsigned ElemIndex) {
+ if (!this->emitConst(IL->getValue(), Init))
return false;
- if (InitT != TargetT) {
- if (!this->emitCast(InitT, TargetT, E))
- return false;
- }
- return this->emitInitElem(TargetT, ElemIndex, Init);
+ return this->emitInitElem(TargetT, ElemIndex, IL);
};
if (!EmbedS->doForEachDataElement(Eval, ElementIndex))
return false;