summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-11-19 00:03:54 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-11-19 00:03:54 +0000
commit70effde0af12e768a5890411dc7e33ea7596fed3 (patch)
tree99bd2d80d2f9c3ccd638b4c8613d4dcb0bcba7fb /clang/lib
parent905c41b00d1b08b2101e5cf4aa7671345d76b8d3 (diff)
downloadbcm5719-llvm-70effde0af12e768a5890411dc7e33ea7596fed3.tar.gz
bcm5719-llvm-70effde0af12e768a5890411dc7e33ea7596fed3.zip
[MS ABI] Let arbitrary entities participate in vftable ordering
In the Microsoft ABI, the vftable is laid out in the order in the declaration order of the entities defined within it. Obviously, only virtual methods end up in the vftable but they will be placed into the table at the same position as the first entity with the same name. llvm-svn: 253523
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/VTableBuilder.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 6829da5bb14..bae018652f9 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -2882,22 +2882,26 @@ 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 and non-virtual methods).
+ // (including overrides, non-virtual methods and any other named decl that
+ // might be nested within the class).
// 2) In each group, new overloads appear in the reverse order of declaration.
typedef SmallVector<const CXXMethodDecl *, 1> MethodGroup;
SmallVector<MethodGroup, 10> Groups;
typedef llvm::DenseMap<DeclarationName, unsigned> VisitedGroupIndicesTy;
VisitedGroupIndicesTy VisitedGroupIndices;
- for (const auto *MD : RD->methods()) {
- MD = MD->getCanonicalDecl();
+ for (const auto *D : RD->decls()) {
+ const auto *ND = dyn_cast<NamedDecl>(D);
+ if (!ND)
+ continue;
VisitedGroupIndicesTy::iterator J;
bool Inserted;
std::tie(J, Inserted) = VisitedGroupIndices.insert(
- std::make_pair(MD->getDeclName(), Groups.size()));
+ std::make_pair(ND->getDeclName(), Groups.size()));
if (Inserted)
Groups.push_back(MethodGroup());
- if (MD->isVirtual())
- Groups[J->second].push_back(MD);
+ if (const auto *MD = dyn_cast<CXXMethodDecl>(ND))
+ if (MD->isVirtual())
+ Groups[J->second].push_back(MD->getCanonicalDecl());
}
for (const MethodGroup &Group : Groups)
OpenPOWER on IntegriCloud