summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2014-03-26 08:12:53 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2014-03-26 08:12:53 +0000
commitdd0a27664d7062bde97d9c139bd2378e7076b21d (patch)
treef890a8ff11a87af9f7f14f4d93fe91217cbf239b /clang/lib
parent2f8d0104b0ecf5fe8c9267bc546a7a3457069f8f (diff)
downloadbcm5719-llvm-dd0a27664d7062bde97d9c139bd2378e7076b21d.tar.gz
bcm5719-llvm-dd0a27664d7062bde97d9c139bd2378e7076b21d.zip
Fix PR19066 - 0-sized vftable in the presence of virtual inheritance
Reviewed at http://llvm-reviews.chandlerc.com/D3181 llvm-svn: 204786
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/VTableBuilder.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index eef91f7416e..2d1e1a24089 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -2531,6 +2531,7 @@ private:
BasesSetVectorTy VisitedBases;
AddMethods(BaseSubobject(MostDerivedClass, CharUnits::Zero()), 0, 0,
VisitedBases);
+ assert(Components.size() && "vftable can't be empty");
assert(MethodVFTableLocations.empty());
for (MethodInfoMapTy::const_iterator I = MethodInfoMap.begin(),
@@ -2793,6 +2794,14 @@ bool VFTableBuilder::NeedsReturnAdjustingThunk(const CXXMethodDecl *MD) {
return false;
}
+static bool isDirectVBase(const CXXRecordDecl *Base, const CXXRecordDecl *RD) {
+ for (const auto &B : RD->bases()) {
+ if (B.isVirtual() && B.getType()->getAsCXXRecordDecl() == Base)
+ return true;
+ }
+ return false;
+}
+
void VFTableBuilder::AddMethods(BaseSubobject Base, unsigned BaseDepth,
const CXXRecordDecl *LastVBase,
BasesSetVectorTy &VisitedBases) {
@@ -2808,7 +2817,7 @@ void VFTableBuilder::AddMethods(BaseSubobject Base, unsigned BaseDepth,
CharUnits NextBaseOffset;
if (BaseDepth < WhichVFPtr.PathToBaseWithVPtr.size()) {
NextBase = WhichVFPtr.PathToBaseWithVPtr[BaseDepth];
- if (Layout.getVBaseOffsetsMap().count(NextBase)) {
+ if (isDirectVBase(NextBase, RD)) {
NextLastVBase = NextBase;
NextBaseOffset = MostDerivedClassLayout.getVBaseClassOffset(NextBase);
} else {
OpenPOWER on IntegriCloud