From d42217f7570e68d08bde1ff89960e1773b41749a Mon Sep 17 00:00:00 2001 From: Warren Hunt Date: Mon, 14 Oct 2013 20:14:09 +0000 Subject: [PATCH] Correctly check for distructors when realizing vtordisps 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 | 2 +- test/Layout/ms-x86-vtordisp.cpp | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 10c7b5d88f..05eeae154d 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -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(*i)) Work.insert(*i); while (!Work.empty()) { const CXXMethodDecl *MD = *Work.begin(); diff --git a/test/Layout/ms-x86-vtordisp.cpp b/test/Layout/ms-x86-vtordisp.cpp index 45ac649682..06ace3221a 100644 --- a/test/Layout/ms-x86-vtordisp.cpp +++ b/test/Layout/ms-x86-vtordisp.cpp @@ -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 { + virtual ~AT(){} +}; +struct CT : virtual AT { + virtual ~CT(); +}; +CT::~CT(){} + +// CHECK: *** Dumping AST Record Layout +// CHECK: 0 | struct CT +// CHECK: 0 | (CT vbtable pointer) +// CHECK: 4 | struct AT (virtual base) +// CHECK: 4 | (AT vftable pointer) +// CHECK: | [sizeof=8, align=4 +// CHECK: | nvsize=4, nvalign=4] + int a[ sizeof(A)+ sizeof(C)+ -sizeof(D)]; +sizeof(D)+ +sizeof(CT)]; -- 2.40.0