[cfe-commits] r104681 - in /cfe/trunk: include/clang/AST/RecordLayout.h lib/AST/RecordLayout.cpp lib/AST/RecordLayoutBuilder.cpp lib/AST/RecordLayoutBuilder.h
Anders Carlsson
andersca at mac.com
Tue May 25 22:20:58 PDT 2010
Author: andersca
Date: Wed May 26 00:20:58 2010
New Revision: 104681
URL: http://llvm.org/viewvc/llvm-project?rev=104681&view=rev
Log:
No need to use the PrimaryBaseInfo struct in the builder.
Modified:
cfe/trunk/include/clang/AST/RecordLayout.h
cfe/trunk/lib/AST/RecordLayout.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.h
Modified: cfe/trunk/include/clang/AST/RecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=104681&r1=104680&r2=104681&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Wed May 26 00:20:58 2010
@@ -145,7 +145,8 @@
const uint64_t *fieldoffsets, unsigned fieldcount,
uint64_t nonvirtualsize, unsigned nonvirtualalign,
uint64_t SizeOfLargestEmptySubobject,
- const PrimaryBaseInfo &PrimaryBase,
+ const CXXRecordDecl *PrimaryBase,
+ bool PrimaryBaseIsVirtual,
const BaseOffsetsMapTy& BaseOffsets,
const BaseOffsetsMapTy& VBaseOffsets);
Modified: cfe/trunk/lib/AST/RecordLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayout.cpp?rev=104681&r1=104680&r2=104681&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayout.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayout.cpp Wed May 26 00:20:58 2010
@@ -45,7 +45,8 @@
uint64_t nonvirtualsize,
unsigned nonvirtualalign,
uint64_t SizeOfLargestEmptySubobject,
- const PrimaryBaseInfo &PrimaryBase,
+ const CXXRecordDecl *PrimaryBase,
+ bool PrimaryBaseIsVirtual,
const BaseOffsetsMapTy& BaseOffsets,
const BaseOffsetsMapTy& VBaseOffsets)
: Size(size), DataSize(datasize), FieldOffsets(0), Alignment(alignment),
@@ -56,7 +57,7 @@
memcpy(FieldOffsets, fieldoffsets, FieldCount * sizeof(*FieldOffsets));
}
- CXXInfo->PrimaryBase = PrimaryBase;
+ CXXInfo->PrimaryBase = PrimaryBaseInfo(PrimaryBase, PrimaryBaseIsVirtual);
CXXInfo->NonVirtualSize = nonvirtualsize;
CXXInfo->NonVirtualAlign = nonvirtualalign;
CXXInfo->SizeOfLargestEmptySubobject = SizeOfLargestEmptySubobject;
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=104681&r1=104680&r2=104681&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Wed May 26 00:20:58 2010
@@ -24,7 +24,8 @@
ASTRecordLayoutBuilder::ASTRecordLayoutBuilder(ASTContext &Context)
: Context(Context), Size(0), Alignment(8), Packed(false),
UnfilledBitsInLastByte(0), MaxFieldAlignment(0), DataSize(0), IsUnion(false),
- NonVirtualSize(0), NonVirtualAlignment(8), FirstNearlyEmptyVBase(0),
+ PrimaryBase(0), PrimaryBaseIsVirtual(false), NonVirtualSize(0),
+ NonVirtualAlignment(8), FirstNearlyEmptyVBase(0),
SizeOfLargestEmptySubobject(0) { }
/// IsNearlyEmpty - Indicates when a class has a vtable pointer, but
@@ -128,8 +129,8 @@
// If it's not an indirect primary base, then we've found our primary
// base.
if (!IndirectPrimaryBases.count(Base)) {
- PrimaryBase = ASTRecordLayout::PrimaryBaseInfo(Base,
- /*IsVirtual=*/true);
+ PrimaryBase = Base;
+ PrimaryBaseIsVirtual = true;
return;
}
@@ -139,7 +140,7 @@
}
SelectPrimaryVBase(Base);
- if (PrimaryBase.getBase())
+ if (PrimaryBase)
return;
}
}
@@ -175,7 +176,8 @@
if (Base->isDynamicClass()) {
// We found it.
- PrimaryBase = ASTRecordLayout::PrimaryBaseInfo(Base, /*IsVirtual=*/false);
+ PrimaryBase = Base;
+ PrimaryBaseIsVirtual = false;
return;
}
}
@@ -184,20 +186,20 @@
// indirect primary virtual base class, if one exists.
if (RD->getNumVBases() != 0) {
SelectPrimaryVBase(RD);
- if (PrimaryBase.getBase())
+ if (PrimaryBase)
return;
}
// Otherwise, it is the first nearly empty virtual base that is not an
// indirect primary virtual base class, if one exists.
if (FirstNearlyEmptyVBase) {
- PrimaryBase = ASTRecordLayout::PrimaryBaseInfo(FirstNearlyEmptyVBase,
- /*IsVirtual=*/true);
+ PrimaryBase = FirstNearlyEmptyVBase;
+ PrimaryBaseIsVirtual = true;
return;
}
// Otherwise there is no primary base class.
- assert(!PrimaryBase.getBase() && "Should not get here with a primary base!");
+ assert(!PrimaryBase && "Should not get here with a primary base!");
// Allocate the virtual table pointer at offset zero.
assert(DataSize == 0 && "Vtable pointer must be at offset zero!");
@@ -216,17 +218,18 @@
DeterminePrimaryBase(RD);
// If we have a primary base class, lay it out.
- if (const CXXRecordDecl *Base = PrimaryBase.getBase()) {
- if (PrimaryBase.isVirtual()) {
+ if (PrimaryBase) {
+ if (PrimaryBaseIsVirtual) {
// We have a virtual primary base, insert it as an indirect primary base.
- IndirectPrimaryBases.insert(Base);
+ IndirectPrimaryBases.insert(PrimaryBase);
- assert(!VisitedVirtualBases.count(Base) && "vbase already visited!");
- VisitedVirtualBases.insert(Base);
+ assert(!VisitedVirtualBases.count(PrimaryBase) &&
+ "vbase already visited!");
+ VisitedVirtualBases.insert(PrimaryBase);
- LayoutVirtualBase(Base);
+ LayoutVirtualBase(PrimaryBase);
} else
- LayoutNonVirtualBase(Base);
+ LayoutNonVirtualBase(PrimaryBase);
}
// Now lay out the non-virtual bases.
@@ -241,7 +244,7 @@
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
// Skip the primary base.
- if (Base == PrimaryBase.getBase() && !PrimaryBase.isVirtual())
+ if (Base == PrimaryBase && PrimaryBaseIsVirtual)
continue;
// Lay out the base.
@@ -322,8 +325,8 @@
bool PrimaryBaseIsVirtual;
if (MostDerivedClass == RD) {
- PrimaryBase = this->PrimaryBase.getBase();
- PrimaryBaseIsVirtual = this->PrimaryBase.isVirtual();
+ PrimaryBase = this->PrimaryBase;
+ PrimaryBaseIsVirtual = this->PrimaryBaseIsVirtual;
} else {
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
PrimaryBase = Layout.getPrimaryBase();
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.h?rev=104681&r1=104680&r2=104681&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.h (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.h Wed May 26 00:20:58 2010
@@ -61,13 +61,19 @@
/// PrimaryBase - the primary base class (if one exists) of the class
/// we're laying out.
- ASTRecordLayout::PrimaryBaseInfo PrimaryBase;
+ const CXXRecordDecl *PrimaryBase;
+
+ /// PrimaryBaseIsVirtual - Whether the primary base of the class we're laying
+ /// out is virtual.
+ bool PrimaryBaseIsVirtual;
+ typedef llvm::DenseMap<const CXXRecordDecl *, uint64_t> BaseOffsetsMapTy;
+
/// Bases - base classes and their offsets in the record.
- ASTRecordLayout::BaseOffsetsMapTy Bases;
+ BaseOffsetsMapTy Bases;
// VBases - virtual base classes and their offsets in the record.
- ASTRecordLayout::BaseOffsetsMapTy VBases;
+ BaseOffsetsMapTy VBases;
/// IndirectPrimaryBases - Virtual base classes, direct or indirect, that are
/// primary base classes for some other direct or indirect base class.
More information about the cfe-commits
mailing list