From 6701de2abeb9a18fcd54d562d911e3818f2d193c Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 19 Feb 2014 22:06:10 +0000 Subject: MS ABI: Let non-virtual method overloads participate in vftable ordering In the Microsoft ABI, the vftable is laid out as if all methods in every overload set were declared in reverse order of declaration at the point of declaration of the first overload in the set. Previously we only considered virtual methods in an overload set, but MSVC includes non-virtual methods for ordering purposes. Fixes PR18902. llvm-svn: 201722 --- clang/lib/AST/VTableBuilder.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'clang/lib/AST/VTableBuilder.cpp') diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index 30f95d0f25b..e0e30a122a8 100644 --- a/clang/lib/AST/VTableBuilder.cpp +++ b/clang/lib/AST/VTableBuilder.cpp @@ -2789,7 +2789,7 @@ static void GroupNewVirtualOverloads( // Put the virtual methods into VirtualMethods in the proper order: // 1) Group overloads by declaration name. New groups are added to the // vftable in the order of their first declarations in this class - // (including overrides). + // (including overrides and non-virtual methods). // 2) In each group, new overloads appear in the reverse order of declaration. typedef SmallVector MethodGroup; SmallVector Groups; @@ -2798,16 +2798,14 @@ static void GroupNewVirtualOverloads( for (CXXRecordDecl::method_iterator I = RD->method_begin(), E = RD->method_end(); I != E; ++I) { const CXXMethodDecl *MD = *I; - if (!MD->isVirtual()) - continue; VisitedGroupIndicesTy::iterator J; bool Inserted; llvm::tie(J, Inserted) = VisitedGroupIndices.insert( std::make_pair(MD->getDeclName(), Groups.size())); if (Inserted) - Groups.push_back(MethodGroup(1, MD)); - else + Groups.push_back(MethodGroup()); + if (I->isVirtual()) Groups[J->second].push_back(MD); } -- cgit v1.2.3