]> granicus.if.org Git - clang/commitdiff
Preserve the zero-initialization and construction-kind settings when
authorDouglas Gregor <dgregor@apple.com>
Sun, 22 Aug 2010 17:20:18 +0000 (17:20 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 22 Aug 2010 17:20:18 +0000 (17:20 +0000)
instantiating CXXConstructExpr expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111780 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/TreeTransform.h
test/CodeGenCXX/value-init.cpp

index 90ec1bd96a95578f2806e6a39119d543b446ae89..656c03d890b7341e1554b41e88e21d6860f355b4 100644 (file)
@@ -1684,14 +1684,17 @@ public:
                                            SourceLocation Loc,
                                            CXXConstructorDecl *Constructor,
                                            bool IsElidable,
-                                           MultiExprArg Args) {
+                                           MultiExprArg Args,
+                                           bool RequiresZeroInit,
+                             CXXConstructExpr::ConstructionKind ConstructKind) {
     ASTOwningVector<&ActionBase::DeleteExpr> ConvertedArgs(SemaRef);
     if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc, 
                                           ConvertedArgs))
       return getSema().ExprError();
     
     return getSema().BuildCXXConstructExpr(Loc, T, Constructor, IsElidable,
-                                           move_arg(ConvertedArgs));
+                                           move_arg(ConvertedArgs),
+                                           RequiresZeroInit, ConstructKind);
   }
 
   /// \brief Build a new object-construction expression.
@@ -5686,7 +5689,9 @@ TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
 
   return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(),
                                               Constructor, E->isElidable(),
-                                              move_arg(Args));
+                                              move_arg(Args),
+                                              E->requiresZeroInitialization(),
+                                              E->getConstructionKind());
 }
 
 /// \brief Transform a C++ temporary-binding expression.
index 6977e73e8b5ec9ca0b201b6d739dc76d34dfdaaf..c4eb1c8990967041386277c00c171f824424933b 100644 (file)
@@ -111,4 +111,30 @@ namespace zeroinit {
     // CHECK-NEXT: call void @_ZN8zeroinit2X11fEv
     X1().f();
   }
+
+  template<typename>
+  struct X2 : X0 {
+    int x2;
+    void f();
+  };
+
+  template<typename>
+  struct X3 : X2<int> { 
+    X3() : X2<int>() { }
+  };
+  
+
+  // CHECK: define void @_ZN8zeroinit9testX0_X3Ev
+  void testX0_X3() {
+    // CHECK-NOT: call void @llvm.memset
+    // CHECK: call void @_ZN8zeroinit2X3IiEC1Ev
+    // CHECK: call void @_ZN8zeroinit2X2IiE1fEv
+    // CHECK-NEXT: ret void
+    X3<int>().f();
+  }
+
+  // CHECK: define linkonce_odr void @_ZN8zeroinit2X3IiEC2Ev
+  // CHECK: call void @llvm.memset.p0i8.i64
+  // CHECK-NEXT: call void @_ZN8zeroinit2X2IiEC2Ev
+  // CHECK-NEXT: ret void
 }