summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/VTableBuilder.cpp
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2013-11-08 11:45:35 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2013-11-08 11:45:35 +0000
commit2c9341f979378da8af58a9be7eb179294c48378e (patch)
treec468035ac49e0cac9b6ca6b7f958ea5987189f4d /clang/lib/AST/VTableBuilder.cpp
parenta3bac169507a63cf936abe6c2f07354a2e068af4 (diff)
downloadbcm5719-llvm-2c9341f979378da8af58a9be7eb179294c48378e.tar.gz
bcm5719-llvm-2c9341f979378da8af58a9be7eb179294c48378e.zip
Thread the info about vbptr sharing through ASTRecordLayout
Reviewed at http://llvm-reviews.chandlerc.com/D2120 llvm-svn: 194256
Diffstat (limited to 'clang/lib/AST/VTableBuilder.cpp')
-rw-r--r--clang/lib/AST/VTableBuilder.cpp29
1 files changed, 8 insertions, 21 deletions
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 142f5502969..fd768d81260 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -3363,30 +3363,17 @@ void MicrosoftVTableContext::computeVBTableRelatedInformation(
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
BasesSetVectorTy VisitedBases;
- // First, see if the Derived class shared the vbptr
- // with the first non-virtual base.
- for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
- E = RD->bases_end(); I != E; ++I) {
- if (I->isVirtual())
- continue;
-
- const CXXRecordDecl *CurBase = I->getType()->getAsCXXRecordDecl();
- CharUnits DerivedVBPtrOffset = Layout.getVBPtrOffset(),
- BaseOffset = Layout.getBaseClassOffset(CurBase);
- const ASTRecordLayout &BaseLayout = Context.getASTRecordLayout(CurBase);
- if (!BaseLayout.hasVBPtr() ||
- DerivedVBPtrOffset != BaseOffset + BaseLayout.getVBPtrOffset())
- continue;
-
+ // First, see if the Derived class shared the vbptr with a non-virtual base.
+ if (const CXXRecordDecl *VBPtrBase = Layout.getBaseSharingVBPtr()) {
// If the Derived class shares the vbptr with a non-virtual base,
// it inherits its vbase indices.
- computeVBTableRelatedInformation(CurBase);
- for (CXXRecordDecl::base_class_const_iterator J = CurBase->vbases_begin(),
- F = CurBase->vbases_end(); J != F; ++J) {
- const CXXRecordDecl *SubVBase = J->getType()->getAsCXXRecordDecl();
- assert(VBTableIndices.count(ClassPairTy(CurBase, SubVBase)));
+ computeVBTableRelatedInformation(VBPtrBase);
+ for (CXXRecordDecl::base_class_const_iterator I = VBPtrBase->vbases_begin(),
+ E = VBPtrBase->vbases_end(); I != E; ++I) {
+ const CXXRecordDecl *SubVBase = I->getType()->getAsCXXRecordDecl();
+ assert(VBTableIndices.count(ClassPairTy(VBPtrBase, SubVBase)));
VBTableIndices[ClassPairTy(RD, SubVBase)] =
- VBTableIndices[ClassPairTy(CurBase, SubVBase)];
+ VBTableIndices[ClassPairTy(VBPtrBase, SubVBase)];
VisitedBases.insert(SubVBase);
}
}
OpenPOWER on IntegriCloud