If a class has a non-trivial constructor that doesn't take any arguments, we will now make an implicit CXXTemporaryObjectExpr. So 

struct S {
  S();
};

void f() {
 S s;
}

's' here will implicitly be declared as.

S s = S();



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69326 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 8e2302e..e3195a9 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1764,6 +1764,18 @@
   return DeclPtrTy::make(AliasDecl);
 }
 
+void Sema::InitializeVarWithConstructor(VarDecl *VD, 
+                                        CXXConstructorDecl *Constructor,
+                                        QualType DeclInitType, 
+                                        Expr **Exprs, unsigned NumExprs) {
+  Expr *Temp = 
+    new (Context) CXXTemporaryObjectExpr(Constructor, DeclInitType,
+                                         SourceLocation(), 
+                                         Exprs, NumExprs,
+                                         SourceLocation());
+  VD->setInit(Temp);
+}
+
 /// AddCXXDirectInitializerToDecl - This action is called immediately after 
 /// ActOnDeclarator, when a C++ direct initializer is present.
 /// e.g: "int x(1);"
@@ -1827,17 +1839,9 @@
     if (!Constructor)
       RealDecl->setInvalidDecl();
     else {
-      // Let clients know that initialization was done with a direct
-      // initializer.
       VDecl->setCXXDirectInitializer(true);
-
-      Expr *Temp = 
-        new (Context) CXXTemporaryObjectExpr(Constructor, DeclInitType,
-                                             SourceLocation(), 
-                                             (Expr**)Exprs.release(), 
-                                             NumExprs,
-                                             SourceLocation());
-      VDecl->setInit(Temp);
+      InitializeVarWithConstructor(VDecl, Constructor, DeclInitType, 
+                                   (Expr**)Exprs.release(), NumExprs);
     }
     return;
   }