aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-08-05 22:37:18 +0000
committerMike Stump <mrs@apple.com>2009-08-05 22:37:18 +0000
commit6f376336138ea719e3c4757ae046a5768043b276 (patch)
tree4721570e1f90e01e46ddac8f5b7443914789c1f6 /include
parentaed2b3e5f3a1f849ee864c2a12e8d6a1bf8150c5 (diff)
Calculate the primary base class better and use that when laying down
the vtable. Still a work in progress. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/AST/DeclCXX.h4
-rw-r--r--include/clang/AST/RecordLayout.h15
2 files changed, 17 insertions, 2 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 18ff6a3b81..19c21cba77 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -398,6 +398,10 @@ public:
virtual void Destroy(ASTContext& C);
+ bool isDynamicClass() const {
+ return Polymorphic || NumVBases!=0;
+ }
+
/// setBases - Sets the base classes of this struct or class.
void setBases(ASTContext &C,
CXXBaseSpecifier const * const *Bases, unsigned NumBases);
diff --git a/include/clang/AST/RecordLayout.h b/include/clang/AST/RecordLayout.h
index c657ddb869..bb40da7647 100644
--- a/include/clang/AST/RecordLayout.h
+++ b/include/clang/AST/RecordLayout.h
@@ -54,6 +54,9 @@ class ASTRecordLayout {
/// which is the alignment of the object without virtual bases.
uint64_t NonVirtualAlign;
+ /// PrimaryBase - The primary base for our vtable.
+ const CXXRecordDecl *PrimaryBase;
+
/// BaseOffsets - Contains a map from base classes to their offset.
/// FIXME: Does it make sense to store offsets for virtual base classes
/// here?
@@ -83,8 +86,8 @@ class ASTRecordLayout {
ASTRecordLayout(uint64_t size, unsigned alignment, uint64_t datasize,
const uint64_t *fieldoffsets, unsigned fieldcount,
uint64_t nonvirtualsize, unsigned nonvirtualalign,
- const CXXRecordDecl **bases, const uint64_t *baseoffsets,
- unsigned basecount)
+ const CXXRecordDecl *PB, const CXXRecordDecl **bases,
+ const uint64_t *baseoffsets, unsigned basecount)
: Size(size), DataSize(datasize), FieldOffsets(0), Alignment(alignment),
FieldCount(fieldcount), CXXInfo(new CXXRecordLayoutInfo) {
if (FieldCount > 0) {
@@ -93,6 +96,7 @@ class ASTRecordLayout {
FieldOffsets[i] = fieldoffsets[i];
}
+ CXXInfo->PrimaryBase = PB;
CXXInfo->NonVirtualSize = nonvirtualsize;
CXXInfo->NonVirtualAlign = nonvirtualalign;
for (unsigned i = 0; i != basecount; ++i)
@@ -146,6 +150,13 @@ public:
return CXXInfo->NonVirtualAlign;
}
+ /// getPrimaryBase - Get the primary base.
+ const CXXRecordDecl *getPrimaryBase() const {
+ assert(CXXInfo && "Record layout does not have C++ specific info!");
+
+ return CXXInfo->PrimaryBase;
+ }
+
/// getBaseClassOffset - Get the offset, in bits, for the given base class.
uint64_t getBaseClassOffset(const CXXRecordDecl *Base) const {
assert(CXXInfo && "Record layout does not have C++ specific info!");