Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" and
modify the semantics slightly to accomodate default constructors (I
hope).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131087 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 9099cd5..ab097e4 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -33,11 +33,11 @@
     Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
     Abstract(false), IsStandardLayout(true), HasNoNonEmptyBases(true),
     HasPrivateFields(false), HasProtectedFields(false), HasPublicFields(false),
-    HasTrivialConstructor(true), HasConstExprNonCopyMoveConstructor(false),
-    HasTrivialCopyConstructor(true), HasTrivialMoveConstructor(true),
-    HasTrivialCopyAssignment(true), HasTrivialMoveAssignment(true),
-    HasTrivialDestructor(true), HasNonLiteralTypeFieldsOrBases(false),
-    ComputedVisibleConversions(false),
+    HasTrivialDefaultConstructor(true),
+    HasConstExprNonCopyMoveConstructor(false), HasTrivialCopyConstructor(true),
+    HasTrivialMoveConstructor(true), HasTrivialCopyAssignment(true),
+    HasTrivialMoveAssignment(true), HasTrivialDestructor(true),
+    HasNonLiteralTypeFieldsOrBases(false), ComputedVisibleConversions(false),
     DeclaredDefaultConstructor(false), DeclaredCopyConstructor(false), 
     DeclaredCopyAssignment(false), DeclaredDestructor(false),
     NumBases(0), NumVBases(0), Bases(), VBases(),
@@ -165,8 +165,9 @@
       data().Empty = false;
       
       // C++ [class.ctor]p5:
-      //   A constructor is trivial if its class has no virtual base classes.
-      data().HasTrivialConstructor = false;
+      //   A default constructor is trivial [...] if:
+      //    -- its class has [...] no virtual bases
+      data().HasTrivialDefaultConstructor = false;
 
       // C++0x [class.copy]p13:
       //   A copy/move constructor for class X is trivial if it is neither
@@ -188,10 +189,11 @@
       data().IsStandardLayout = false;
     } else {
       // C++ [class.ctor]p5:
-      //   A constructor is trivial if all the direct base classes of its
-      //   class have trivial constructors.
-      if (!BaseClassDecl->hasTrivialConstructor())
-        data().HasTrivialConstructor = false;
+      //   A default constructor is trivial [...] if:
+      //    -- all the direct base classes of its class have trivial default
+      //       constructors.
+      if (!BaseClassDecl->hasTrivialDefaultConstructor())
+        data().HasTrivialDefaultConstructor = false;
       
       // C++0x [class.copy]p13:
       //   A copy/move constructor for class X is trivial if [...]
@@ -421,8 +423,10 @@
       //   polymorphic class.
       data().Polymorphic = true;
       
-      // None of the special member functions are trivial.
-      data().HasTrivialConstructor = false;
+      // C++0x [class.ctor]p5
+      //   A default constructor is trivial [...] if:
+      //    -- its class has no virtual functions [...]
+      data().HasTrivialDefaultConstructor = false;
 
       // C++0x [class.copy]p13:
       //   A copy/move constructor for class X is trivial if [...]
@@ -497,11 +501,10 @@
     //   A POD-struct is an aggregate class [...]
     data().PlainOldData = false;
 
-    // C++ [class.ctor]p5:
-    //   A constructor is trivial if it is an implicitly-declared default
-    //   constructor.
-    // FIXME: C++0x: don't do this for "= default" default constructors.
-    data().HasTrivialConstructor = false;
+    // C++0x [class.ctor]p5:
+    //   A default constructor is trivial if it is not user-provided [...]
+    if (Constructor->isUserProvided())
+      data().HasTrivialDefaultConstructor = false;
 
     // Note when we have a user-declared copy or move constructor, which will
     // suppress the implicit declaration of those constructors.
@@ -511,16 +514,16 @@
         data().DeclaredCopyConstructor = true;
 
         // C++0x [class.copy]p13:
-        //   A copy/move constructor for class X is trivial if it is neither
-        //   user-provided nor deleted
-        // FIXME: C++0x: don't do this for "= default" copy constructors.
-        data().HasTrivialCopyConstructor = false;
+        //   A copy/move constructor for class X is trivial if it is not
+        //   user-provided [...]
+        if (Constructor->isUserProvided())
+          data().HasTrivialCopyConstructor = false;
       } else if (Constructor->isMoveConstructor()) {
         // C++0x [class.copy]p13:
-        //   A copy/move constructor for class X is trivial if it is neither
-        //   user-provided nor deleted
-        // FIXME: C++0x: don't do this for "= default" move constructors.
-        data().HasTrivialMoveConstructor = false;
+        //   A copy/move constructor for class X is trivial if it is not
+        //   user-provided [...]
+        if (Constructor->isUserProvided())
+          data().HasTrivialMoveConstructor = false;
       }
     }
     if (Constructor->isConstExpr() &&
@@ -676,7 +679,7 @@
     if (!T->isPODType())
       data().PlainOldData = false;
     if (T->isReferenceType()) {
-      data().HasTrivialConstructor = false;
+      data().HasTrivialDefaultConstructor = false;
 
       // C++0x [class]p7:
       //   A standard-layout class is a class that:
@@ -691,8 +694,13 @@
     if (const RecordType *RecordTy = T->getAs<RecordType>()) {
       CXXRecordDecl* FieldRec = cast<CXXRecordDecl>(RecordTy->getDecl());
       if (FieldRec->getDefinition()) {
-        if (!FieldRec->hasTrivialConstructor())
-          data().HasTrivialConstructor = false;
+        // C++0x [class.ctor]p5:
+        //   A defulat constructor is trivial [...] if:
+        //    -- for all the non-static data members of its class that are of
+        //       class type (or array thereof), each such class has a trivial
+        //       default constructor.
+        if (!FieldRec->hasTrivialDefaultConstructor())
+          data().HasTrivialDefaultConstructor = false;
 
         // C++0x [class.copy]p13:
         //   A copy/move constructor for class X is trivial if [...]