================
@@ -6033,6 +6020,37 @@ static QualType getIntTypeForBitwidthOrBitInt(ASTContext
&C, unsigned Bits,
return Ty;
}
+static Expr *buildInitListValue(Sema &SemaRef, Expr *E) {
+ auto *ILE = dyn_cast<InitListExpr>(E);
+ if (!ILE)
+ return E;
+ if (ILE->isTransparent())
+ return buildInitListValue(SemaRef, ILE->getInit(0));
+ QualType Ty = ILE->getType();
+ bool IsEmptyScalar = ILE->getNumInits() == 0 && Ty->isScalarType();
+ SourceLocation LBrace = ILE->getLBraceLoc();
+ if (!SemaRef.getLangOpts().CPlusPlus) {
+ if (!IsEmptyScalar)
+ return E;
+ ExprResult Zero = SemaRef.PerformImplicitConversion(
+ SemaRef.ActOnIntegerConstant(LBrace, 0).get(), Ty,
+ AssignmentAction::Converting);
+ return Zero.isUsable() ? Zero.get() : E;
+ }
+ InitListExpr *Syntactic = ILE->getSyntacticForm();
+ if ((!IsEmptyScalar && !Ty->isRecordType()) || !Syntactic)
+ return E;
+ Sema::TentativeAnalysisScope Trap(SemaRef);
+ ExprResult List = CaptureVars(SemaRef).TransformExpr(Syntactic);
+ if (List.isInvalid())
+ return E;
+ Expr *ListExpr = List.get();
+ ExprResult Value = SemaRef.BuildCXXTypeConstructExpr(
+ SemaRef.Context.getTrivialTypeSourceInfo(Ty, LBrace), LBrace, ListExpr,
+ ILE->getRBraceLoc(), /*ListInitialization=*/true);
+ return Value.isUsable() ? Value.get() : E;
----------------
akash-manna-sky wrote:
I think it doesn't. The identity case hands the list back as is (that's what
`tryBuildCapture` already does, and the transforms crash on it), and for an
aggregate it asserts on a user-defined sequence with no conversion function.
Only `InitializationSequence` takes a list apart, hence
`BuildCXXTypeConstructExpr`.
https://github.com/llvm/llvm-project/pull/233248
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits