================
@@ -3637,6 +3637,34 @@ bool 
Sema::CanPerformAggregateInitializationForOverloadResolution(
   return !Check.HadError();
 }
 
+MultiExprArg Sema::getInitsWithEmbedExpanded(InitListExpr *ILE,
+                                             SmallVectorImpl<Expr *> &Storage) 
{
+  if (llvm::none_of(ILE->inits(), [](const Expr *Init) {
+        return isa<EmbedExpr>(Init->IgnoreParenImpCasts());
+      }))
+    return MultiExprArg(ILE->getInits(), ILE->getNumInits());
+
+  Storage.clear();
+  Storage.reserve(ILE->getNumInitsWithEmbedExpanded());
+  for (Expr *Init : ILE->inits()) {
+    auto *Embed = dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts());
+    if (!Embed) {
+      Storage.push_back(Init);
+      continue;
+    }
+    const StringLiteral *Data = Embed->getDataStringLiteral();
+    QualType ElemTy = Embed->getType();
+    unsigned Width = Context.getIntWidth(ElemTy);
+    for (unsigned I = Embed->getStartingElementPos(),
+                  E = I + Embed->getDataElementCount();
+         I != E; ++I)
+      Storage.push_back(IntegerLiteral::Create(
----------------
efriedma-quic wrote:

Can we make an EmbedExpr instead?  I'd like to try to preserve the information 
that this originally came from an embed, if we can.

https://github.com/llvm/llvm-project/pull/231938
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to