]> granicus.if.org Git - clang/commitdiff
Fix delegating constructors stylistic issues.
authorSean Hunt <scshunt@csclub.uwaterloo.ca>
Tue, 3 May 2011 20:19:28 +0000 (20:19 +0000)
committerSean Hunt <scshunt@csclub.uwaterloo.ca>
Tue, 3 May 2011 20:19:28 +0000 (20:19 +0000)
Material bugfixes to come this afternoon.

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

lib/CodeGen/CGClass.cpp
lib/CodeGen/CGExprCXX.cpp
lib/Sema/SemaInit.cpp

index ca8b6576c7ad41d2260502e050079ab1f8201528..12946423adf43ef82f7b191509f8e5f833f3b200 100644 (file)
@@ -726,12 +726,13 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
        B != E; ++B) {
     CXXCtorInitializer *Member = (*B);
     
-    if (Member->isBaseInitializer())
+    if (Member->isBaseInitializer()) {
       EmitBaseInitializer(*this, ClassDecl, Member, CtorType);
-    else if (Member->isAnyMemberInitializer())
+    } else {
+      assert(Member->isAnyMemberInitializer() &&
+            "Delegating initializer on non-delegating constructor");
       MemberInitializers.push_back(Member);
-    else
-      llvm_unreachable("Delegating initializer on non-delegating constructor");
+    }
   }
 
   InitializeVTablePointers(ClassDecl);
index bdaa873f18328fa0580b1d2e71c92305f01752a3..eb0e2068dbef0edebe8023ca170ba2319cde59a2 100644 (file)
@@ -404,17 +404,25 @@ CodeGenFunction::EmitCXXConstructExpr(const CXXConstructExpr *E,
   }
   else {
     CXXCtorType Type;
-    CXXConstructExpr::ConstructionKind K = E->getConstructionKind();
-    if (K == CXXConstructExpr::CK_Delegating) {
+    bool ForVirtualBase = false;
+
+    switch (E->getConstructionKind()) {
+     case CXXConstructExpr::CK_Delegating:
       // We should be emitting a constructor; GlobalDecl will assert this
       Type = CurGD.getCtorType();
-    } else {
-      Type = (E->getConstructionKind() == CXXConstructExpr::CK_Complete)
-             ? Ctor_Complete : Ctor_Base;
-    }
+      break;
 
-    bool ForVirtualBase = 
-      E->getConstructionKind() == CXXConstructExpr::CK_VirtualBase;
+     case CXXConstructExpr::CK_Complete:
+      Type = Ctor_Complete;
+      break;
+
+     case CXXConstructExpr::CK_VirtualBase:
+      ForVirtualBase = true;
+      // fall-through
+
+     case CXXConstructExpr::CK_NonVirtualBase:
+      Type = Ctor_Base;
+    }
     
     // Call the constructor.
     EmitCXXConstructorCall(CD, Type, ForVirtualBase, Dest.getAddr(),
index ca3fd6dfcb456eac43a3cdf42cb00dfb140d2a4f..4b458160d2619a390bc4732941752d644b2ee3c0 100644 (file)
@@ -4060,8 +4060,7 @@ InitializationSequence::Perform(Sema &S,
           ConstructKind = Entity.getBaseSpecifier()->isVirtual() ?
             CXXConstructExpr::CK_VirtualBase :
             CXXConstructExpr::CK_NonVirtualBase;
-        }
-        if (Entity.getKind() == InitializedEntity::EK_Delegating) {
+        } else if (Entity.getKind() == InitializedEntity::EK_Delegating) {
           ConstructKind = CXXConstructExpr::CK_Delegating;
         }