Author: Timm Baeder Date: 2025-08-10T19:02:08+02:00 New Revision: 2b4b721faf852a405b25064c0d3b59a2372efe2b
URL: https://github.com/llvm/llvm-project/commit/2b4b721faf852a405b25064c0d3b59a2372efe2b DIFF: https://github.com/llvm/llvm-project/commit/2b4b721faf852a405b25064c0d3b59a2372efe2b.diff LOG: [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. Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 5275b86a57a47..8e651cf060620 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits