[cfe-commits] r105007 - /cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Anders Carlsson
andersca at mac.com
Fri May 28 14:24:37 PDT 2010
Author: andersca
Date: Fri May 28 16:24:37 2010
New Revision: 105007
URL: http://llvm.org/viewvc/llvm-project?rev=105007&view=rev
Log:
Rename BaseInfo to BaseSubobjectInfo.
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=105007&r1=105006&r2=105007&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri May 28 16:24:37 2010
@@ -23,14 +23,33 @@
namespace {
-struct BaseInfo {
+/// BaseSubobjectInfo - Represents a single base subobject in a complete class.
+/// For a class hierarchy like
+///
+/// class A { };
+/// class B : A { };
+/// class C : A, B { };
+///
+/// The BaseSubobjectInfo graph for C will have three BaseSubobjectInfo
+/// instances, one for B and two for A.
+///
+/// If a base is virtual, it will only have one BaseSubobjectInfo allocated.
+struct BaseSubobjectInfo {
+ /// Class - The class for this base info.
const CXXRecordDecl *Class;
+
+ /// IsVirtual - Whether the BaseInfo represents a virtual base or not.
bool IsVirtual;
+ /// Bases - Information about the base subobjects.
+ llvm::SmallVector<BaseSubobjectInfo*, 4> Bases;
+
+ /// PrimaryVirtualBase - Holds the base info for the primary virtual base of
+ /// this base info (if one exists).
const CXXRecordDecl *PrimaryVirtualBase;
-
- llvm::SmallVector<BaseInfo*, 4> Bases;
- const BaseInfo *Derived;
+
+ // FIXME: Document.
+ const BaseSubobjectInfo *Derived;
};
/// EmptySubobjectMap - Keeps track of which empty subobjects exist at different
@@ -50,18 +69,20 @@
/// member subobject that is empty.
void ComputeEmptySubobjectSizes();
- llvm::DenseMap<const CXXRecordDecl *, BaseInfo *> VirtualBaseInfo;
- llvm::DenseMap<const CXXRecordDecl *, BaseInfo *> NonVirtualBaseInfo;
+ llvm::DenseMap<const CXXRecordDecl *, BaseSubobjectInfo *> VirtualBaseInfo;
+ llvm::DenseMap<const CXXRecordDecl *, BaseSubobjectInfo *> NonVirtualBaseInfo;
- BaseInfo *ComputeBaseInfo(const CXXRecordDecl *RD, bool IsVirtual,
- const BaseInfo *Derived);
+ BaseSubobjectInfo *ComputeBaseInfo(const CXXRecordDecl *RD, bool IsVirtual,
+ const BaseSubobjectInfo *Derived);
void ComputeBaseInfo();
bool CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD, uint64_t Offset);
void AddSubobjectAtOffset(const CXXRecordDecl *RD, uint64_t Offset);
- bool CanPlaceBaseSubobjectAtOffset(const BaseInfo *Info, uint64_t Offset);
- void UpdateEmptyBaseSubobjects(const BaseInfo *Info, uint64_t Offset);
+ bool CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
+ uint64_t Offset);
+ void UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
+ uint64_t Offset);
bool CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
@@ -148,22 +169,22 @@
}
}
-BaseInfo *EmptySubobjectMap::ComputeBaseInfo(const CXXRecordDecl *RD,
- bool IsVirtual,
- const BaseInfo *Derived) {
- BaseInfo *Info;
+BaseSubobjectInfo *
+EmptySubobjectMap::ComputeBaseInfo(const CXXRecordDecl *RD, bool IsVirtual,
+ const BaseSubobjectInfo *Derived) {
+ BaseSubobjectInfo *Info;
if (IsVirtual) {
- BaseInfo *&InfoSlot = VirtualBaseInfo[RD];
+ BaseSubobjectInfo *&InfoSlot = VirtualBaseInfo[RD];
if (InfoSlot) {
assert(InfoSlot->Class == RD && "Wrong class for virtual base info!");
return InfoSlot;
}
- InfoSlot = new (Context) BaseInfo;
+ InfoSlot = new (Context) BaseSubobjectInfo;
Info = InfoSlot;
} else {
- Info = new (Context) BaseInfo;
+ Info = new (Context) BaseSubobjectInfo;
}
Info->Class = RD;
@@ -202,7 +223,8 @@
const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
- BaseInfo *Info = ComputeBaseInfo(BaseDecl, IsVirtual, /*Derived=*/0);
+ BaseSubobjectInfo *Info =
+ ComputeBaseInfo(BaseDecl, IsVirtual, /*Derived=*/0);
if (IsVirtual) {
// ComputeBaseInfo has already added this base for us.
continue;
@@ -248,14 +270,14 @@
}
bool
-EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(const BaseInfo *Info,
+EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
uint64_t Offset) {
if (!CanPlaceSubobjectAtOffset(Info->Class, Offset))
return false;
// Traverse all non-virtual bases.
for (unsigned I = 0, E = Info->Bases.size(); I != E; ++I) {
- BaseInfo* Base = Info->Bases[I];
+ BaseSubobjectInfo* Base = Info->Bases[I];
if (Base->IsVirtual)
continue;
@@ -267,7 +289,7 @@
}
if (Info->PrimaryVirtualBase) {
- BaseInfo *PrimaryVirtualBaseInfo =
+ BaseSubobjectInfo *PrimaryVirtualBaseInfo =
VirtualBaseInfo.lookup(Info->PrimaryVirtualBase);
assert(PrimaryVirtualBaseInfo && "Didn't find base info!");
@@ -294,13 +316,13 @@
return true;
}
-void EmptySubobjectMap::UpdateEmptyBaseSubobjects(const BaseInfo *Info,
+void EmptySubobjectMap::UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
uint64_t Offset) {
AddSubobjectAtOffset(Info->Class, Offset);
// Traverse all non-virtual bases.
for (unsigned I = 0, E = Info->Bases.size(); I != E; ++I) {
- BaseInfo* Base = Info->Bases[I];
+ BaseSubobjectInfo* Base = Info->Bases[I];
if (Base->IsVirtual)
continue;
@@ -311,7 +333,7 @@
}
if (Info->PrimaryVirtualBase) {
- BaseInfo *PrimaryVirtualBaseInfo =
+ BaseSubobjectInfo *PrimaryVirtualBaseInfo =
VirtualBaseInfo.lookup(Info->PrimaryVirtualBase);
assert(PrimaryVirtualBaseInfo && "Didn't find base info!");
@@ -341,7 +363,7 @@
if (!SizeOfLargestEmptySubobject)
return true;
- BaseInfo *Info;
+ BaseSubobjectInfo *Info;
if (BaseIsVirtual)
Info = VirtualBaseInfo.lookup(RD);
More information about the cfe-commits
mailing list