@@ -5760,6 +5760,8 @@ std::string Converter::ConvertIRFragment(
57605760 if (borrows_ && isFresh () && !CreatesTemporary (arg)) {
57615761 value = std::format (" ({{ {} }})" , value);
57625762 borrows_ = false ;
5763+ } else if (IsStructLiteral (arg)) {
5764+ value = std::format (" ({})" , value);
57635765 }
57645766 borrows_ |= outer_borrows;
57655767 result += value;
@@ -5937,22 +5939,25 @@ Converter::ConvertInitFragment(clang::Expr *expr,
59375939
59385940 Buffer buf (*this );
59395941 PushExprKind push (*this , ExprKind::RValue);
5940- ConvertConstructFromArgs (type, all_args.drop_front (tgt_ir->params .size ()),
5941- expr->getExprLoc ());
5942- return std::move (buf).str ();
5942+ auto *init = ConvertConstructFromArgs (
5943+ type, all_args.drop_front (tgt_ir->params .size ()), expr->getExprLoc ());
5944+ auto value = std::move (buf).str ();
5945+ return IsStructLiteral (init) ? std::format (" ({})" , value) : value;
59435946}
59445947
5945- void Converter::ConvertConstructFromArgs (clang::QualType type,
5946- llvm::ArrayRef<clang::Expr *> args,
5947- clang::SourceLocation loc) {
5948+ clang::Expr *
5949+ Converter::ConvertConstructFromArgs (clang::QualType type,
5950+ llvm::ArrayRef<clang::Expr *> args,
5951+ clang::SourceLocation loc) {
59485952 auto *init = BuildInitExpr (GetSema (), type, args, loc);
59495953 assert (init && " type cannot be initialized from the arguments" );
59505954 if (args.empty () &&
59515955 !clang::isa<clang::CXXConstructExpr>(init->IgnoreImplicit ())) {
59525956 StrCat (GetDefaultAsString (type));
5953- return ;
5957+ return init ;
59545958 }
59555959 ConvertInit (type, init);
5960+ return init;
59565961}
59575962
59585963void Converter::ConvertInit (clang::QualType type, clang::Expr *init) {
0 commit comments