https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/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.

>From 5b49bf6d788009dde458de71bb9470bf04b47e8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com>
Date: Sun, 10 Aug 2025 18:27:51 +0200
Subject: [PATCH] [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.
---
 clang/lib/AST/ByteCode/Compiler.cpp | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

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

Reply via email to