]> granicus.if.org Git - clang/commitdiff
Correctly check for distructors when realizing vtordisps
authorWarren Hunt <whunt@google.com>
Mon, 14 Oct 2013 20:14:09 +0000 (20:14 +0000)
committerWarren Hunt <whunt@google.com>
Mon, 14 Oct 2013 20:14:09 +0000 (20:14 +0000)
This patch fixes the distructor test when checking for vtordisp requirements in
microsoft record layout.  A test case is also included.

Addresses:
http://llvm.org/bugs/show_bug.cgi?id=16406#c7

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

lib/AST/RecordLayoutBuilder.cpp
test/Layout/ms-x86-vtordisp.cpp

index 10c7b5d88fbde04162c841a2211bc3e2c588d7a6..05eeae154d0645e5cfe4b56116b3da396d564120 100644 (file)
@@ -2989,7 +2989,7 @@ MicrosoftRecordLayoutBuilder::computeVtorDispSet(const CXXRecordDecl *RD) {
     for (CXXRecordDecl::method_iterator i = RD->method_begin(),
                                         e = RD->method_end();
          i != e; ++i)
-      if ((*i)->isVirtual() && (*i) != RD->getDestructor())
+      if ((*i)->isVirtual() && !isa<CXXDestructorDecl>(*i))
         Work.insert(*i);
     while (!Work.empty()) {
       const CXXMethodDecl *MD = *Work.begin();
index 45ac64968210360b9a53ac7c80dd0ec1f8d76c7e..06ace3221a61059cf23d5f891384194b6770bd09 100644 (file)
@@ -91,7 +91,24 @@ struct __declspec(align(32)) D : virtual B0, virtual B1  {
 // CHECK:      | [sizeof=96, align=32
 // CHECK:      |  nvsize=12, nvalign=4]
 
+struct AT {\r
+       virtual ~AT(){}\r
+};\r
+struct CT : virtual AT {\r
+       virtual ~CT();\r
+};\r
+CT::~CT(){}
+
+// CHECK: *** Dumping AST Record Layout\r
+// CHECK:    0 | struct CT\r
+// CHECK:    0 |   (CT vbtable pointer)\r
+// CHECK:    4 |   struct AT (virtual base)\r
+// CHECK:    4 |     (AT vftable pointer)\r
+// CHECK:      | [sizeof=8, align=4\r
+// CHECK:      |  nvsize=4, nvalign=4]\r
+
 int a[
 sizeof(A)+
 sizeof(C)+
-sizeof(D)];
+sizeof(D)+
+sizeof(CT)];