[llvm-branch-commits] [cfe-branch] r105032 - in /cfe/branches/Apple/whitney: lib/CodeGen/CGExprConstant.cpp test/CodeGenCXX/pointers-to-data-members.cpp

Daniel Dunbar daniel at zuster.org
Fri May 28 16:06:30 PDT 2010


Author: ddunbar
Date: Fri May 28 18:06:30 2010
New Revision: 105032

URL: http://llvm.org/viewvc/llvm-project?rev=105032&view=rev
Log:
Merge r104868:
--
Author: Anders Carlsson <andersca at mac.com>
Date:   Thu May 27 18:51:01 2010 +0000

    When null-initializing bases with data member pointers, don't assert on virtual bases. Just initialize them to null.

Modified:
    cfe/branches/Apple/whitney/lib/CodeGen/CGExprConstant.cpp
    cfe/branches/Apple/whitney/test/CodeGenCXX/pointers-to-data-members.cpp

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGExprConstant.cpp?rev=105032&r1=105031&r2=105032&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGExprConstant.cpp Fri May 28 18:06:30 2010
@@ -1009,7 +1009,11 @@
     // Go through all bases and fill in any null pointer to data members.
     for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
          E = RD->bases_end(); I != E; ++I) {
-      assert(!I->isVirtual() && "Should not see virtual bases here!");
+      if (I->isVirtual()) {
+        // FIXME: We should initialize null pointer to data members in virtual
+        // bases here.
+        continue;
+      }
       
       const CXXRecordDecl *BaseDecl = 
       cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
@@ -1088,7 +1092,11 @@
     // Go through all bases and fill in any null pointer to data members.
     for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
          E = RD->bases_end(); I != E; ++I) {
-      assert(!I->isVirtual() && "Should not see virtual bases here!");
+      if (I->isVirtual()) {
+        // FIXME: We should initialize null pointer to data members in virtual
+        // bases here.
+        continue;
+      }
 
       const CXXRecordDecl *BaseDecl = 
         cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());

Modified: cfe/branches/Apple/whitney/test/CodeGenCXX/pointers-to-data-members.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGenCXX/pointers-to-data-members.cpp?rev=105032&r1=105031&r2=105032&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGenCXX/pointers-to-data-members.cpp (original)
+++ cfe/branches/Apple/whitney/test/CodeGenCXX/pointers-to-data-members.cpp Fri May 28 18:06:30 2010
@@ -151,3 +151,24 @@
 }
 
 }
+
+namespace VirtualBases {
+
+struct A {
+  char c;
+  int A::*i;
+};
+
+// FIXME: A::i should be initialized to -1 here.
+struct B : virtual A { };
+B b;
+
+// FIXME: A::i should be initialized to -1 here.
+struct C : virtual A { int A::*i; };
+C c;
+
+// FIXME: C::A::i should be initialized to -1 here.
+struct D : C { int A::*i; };
+D d;
+
+}





More information about the llvm-branch-commits mailing list