[clang] [CIR] Implement LValue InitListExpr and FunctionalCastExpr lowering (PR #192298)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 15 12:03:33 PDT 2026
================
@@ -1015,83 +1010,15 @@ clang::QualType CIRGenFunction::buildFunctionArgList(clang::GlobalDecl gd,
return retTy;
}
-static std::variant<LValue, RValue>
-emitPseudoObjectExpr(CIRGenFunction &cgf, const PseudoObjectExpr *e,
- bool forLValue, AggValueSlot slot) {
- using OVMD = CIRGenFunction::OpaqueValueMappingData;
- SmallVector<OVMD> opaques;
- llvm::scope_exit opaque_cleanup{
- [&]() { llvm::for_each(opaques, [&](OVMD &o) { o.unbind(cgf); }); }};
-
- // Find the result expression, if any.
- const Expr *resultExpr = e->getResultExpr();
- std::variant<LValue, RValue> result;
-
- for (const Expr *semantic : e->semantics()) {
- // If this semantic expression is an opaque value, bind it
- // to the result of its source expression.
- if (const auto *ov = dyn_cast<OpaqueValueExpr>(semantic)) {
-
- // Skip unique OVEs.
- if (ov->isUnique()) {
- // FIXME: This doesn't really affect anything, but I cannot find a test
- // for this, so leave an ErrorNYI here until we can find one.
- cgf.cgm.errorNYI(e->getSourceRange(),
- "emitPseudoObjectExpr skipped for uniqueness");
- assert(ov != resultExpr &&
- "A unique OVE cannot be used as the result expression");
- continue;
- }
-
- // If this is the result expression, we may need to evaluate
- // directly into the slot.
- OVMD opaqueData;
- if (ov == resultExpr && ov->isPRValue() && !forLValue &&
- CIRGenFunction::hasAggregateEvaluationKind(ov->getType())) {
- cgf.cgm.errorNYI(e->getSourceRange(),
- "emitPseudoObjectExpr for RValue & aggregate kind");
- } else {
- opaqueData = OVMD::bind(cgf, ov, ov->getSourceExpr());
-
- // If this is the result, also evaluate the result now.
- if (ov == resultExpr) {
- // FIXME: This doesn't really affect anything, but I cannot find a
- // test for this, so leave an ErrorNYI here until we can find one.
- cgf.cgm.errorNYI(e->getSourceRange(),
- "emitPseudoObjectExpr as result");
- if (forLValue)
- result = cgf.emitLValue(ov);
- else
- cgf.cgm.errorNYI(e->getSourceRange(),
- "emitPseudoObjectExpr as an RValue");
- }
- }
- opaques.push_back(opaqueData);
- } else if (semantic == resultExpr) {
- // Otherwise, if the expression is the result, evaluate it
- // and remember the result.
- if (forLValue)
- result = cgf.emitLValue(semantic);
- else
- cgf.cgm.errorNYI(
- e->getSourceRange(),
- "emitPseudoObjectExpr as an RValue, when semantic is result");
- } else {
- // FIXME: best I can tell, this is only reachable as an r-value, so this
- // isn't properly tested.
- cgf.cgm.errorNYI(e->getSourceRange(),
- "emitPseudoObjectExpr as an ignored value");
- // Otherwise, evaluate the expression in an ignored context.
- cgf.emitIgnoredExpr(semantic);
- }
+LValue CIRGenFunction::emitInitListLValue(const InitListExpr *e) {
+ // Initializing an aggregate temporary in C++11: T{...}.
+ if (!e->isGLValue()) {
----------------
andykaylor wrote:
No need for braces here
https://github.com/llvm/llvm-project/pull/192298
More information about the cfe-commits
mailing list