diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 3544324ae562..b3cb5e25fb35 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1449,8 +1449,8 @@ public: SourceLocation *CommaLocs, SourceLocation RParenLoc); - /// InitializeVarWithConstructor - Creates an implicit - /// CXXTemporaryObjectExpr and sets it as the passed in VarDecl initializer. + /// InitializeVarWithConstructor - Creates an CXXConstructExpr + /// and sets it as the initializer for the the passed in VarDecl. void InitializeVarWithConstructor(VarDecl *VD, CXXConstructorDecl *Constructor, QualType DeclInitType, diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 734b6ce3a0de..82830ef4ad6f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1780,11 +1780,8 @@ void Sema::InitializeVarWithConstructor(VarDecl *VD, CXXConstructorDecl *Constructor, QualType DeclInitType, Expr **Exprs, unsigned NumExprs) { - Expr *Temp = - new (Context) CXXTemporaryObjectExpr(Constructor, DeclInitType, - SourceLocation(), - Exprs, NumExprs, - SourceLocation()); + Expr *Temp = CXXConstructExpr::Create(Context, VD, DeclInitType, Constructor, + false, Exprs, NumExprs); VD->setInit(Temp); }