[clang] [clang-tools-extra] Reland [clang][Sema, Lex, Parse] Preprocessor embed in C and C++ (PR #95802)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 20 11:10:53 PDT 2024


tbaederr wrote:

Here's a quick patch with the cast inserted: 

```diff
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 731153a6ead9..e7fa1a62c277 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1346,13 +1346,30 @@ bool ByteCodeExprGen<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
       }
     }

-    auto Eval = [&](Expr *Init, unsigned ElemIndex) {
-      return visitArrayElemInit(ElemIndex, Init);
-    };
-
+    E->dump();
     unsigned ElementIndex = 0;
     for (const Expr *Init : Inits) {
-      if (auto *EmbedS = dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts())) {
+      if (const auto *EmbedS = dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts())) {
+        QualType TargetType = Init->getType();
+        PrimType TargetT = classifyPrim(Init->getType());
+        TargetType->dump();
+
+
+    auto Eval = [&](const Expr *Init, unsigned ElemIndex) {
+      PrimType InitT = classifyPrim(Init->getType());
+      if (!this->visit(Init))
+        return false;
+      if (InitT != TargetT) {
+        if (!this->emitCast(InitT, TargetT, E))
+          return false;
+      }
+    return this->emitInitElem(TargetT, ElemIndex, Init);
+    };
+
+
+
+
+
         if (!EmbedS->doForEachDataElement(Eval, ElementIndex))
           return false;
       } else {
```

Can you check if that fixes the problem?

https://github.com/llvm/llvm-project/pull/95802


More information about the cfe-commits mailing list