[clang] [clang][CodeGen] Emit file-scope compound literals in a constant context (PR #221390)

Akash Manna via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 11 02:20:57 PDT 2026


================
@@ -7449,6 +7449,31 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
   return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
 }
 
+/// Whether the \p Index-th element of the semantic form of \p ILE initializes
+/// a reference member, so that its initializer is a glvalue that binds.
+static bool initializesReferenceMember(const InitListExpr *ILE,
----------------
akash-manna-sky wrote:

Done, it's just `Init->isGLValue()` now. The one lvalue operand that isn't a reference binding is a string literal (or `@encode`) initializing an array element, so that case is excluded; otherwise CodeGen would emit a pointer where the array contents belong. Added both string-literal shapes to the test.


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


More information about the cfe-commits mailing list