Patch to build list of inherited virtual base classes 
in their order of construction for each class and use it 
to to check on propery order of base class construction 
under -Wreorder option.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75270 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index b942c9c..17726c6 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -825,14 +825,24 @@
                     NumMemInits);
     // Also issue warning if order of ctor-initializer list does not match order
     // of 1) base class declarations and 2) order of non-static data members.
-    // FIXME. proper handling in the presense of virtual base class.
     llvm::SmallVector<const void*, 32> AllBaseOrMembers;
     
     CXXRecordDecl *ClassDecl
       = cast<CXXRecordDecl>(Constructor->getDeclContext());
+    // Push virtual bases before others.
+    for (CXXRecordDecl::base_class_iterator VBase =
+         ClassDecl->vbases_begin(),
+         E = ClassDecl->vbases_end(); VBase != E; ++VBase)
+      AllBaseOrMembers.push_back(VBase->getType()->getAsRecordType());
+      
     for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
-         E = ClassDecl->bases_end(); Base != E; ++Base)
+         E = ClassDecl->bases_end(); Base != E; ++Base) {
+      // Virtuals are alread in the virtual base list and are constructed
+      // first.
+      if (Base->isVirtual())
+        continue;
       AllBaseOrMembers.push_back(Base->getType()->getAsRecordType());
+    }
     
     for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
          E = ClassDecl->field_end(); Field != E; ++Field)