using namespace clang;
-class ASTRecordLayoutBuilder {
+class RecordLayoutBuilder {
// FIXME: Remove this and make the appropriate fields public.
friend class clang::ASTContext;
typedef std::multimap<uint64_t, const CXXRecordDecl *> EmptyClassOffsetsTy;
EmptyClassOffsetsTy EmptyClassOffsets;
- ASTRecordLayoutBuilder(ASTContext &Ctx);
+ RecordLayoutBuilder(ASTContext &Ctx);
void Layout(const RecordDecl *D);
void Layout(const ObjCInterfaceDecl *D);
void UpdateAlignment(unsigned NewAlignment);
- ASTRecordLayoutBuilder(const ASTRecordLayoutBuilder&); // DO NOT IMPLEMENT
- void operator=(const ASTRecordLayoutBuilder&); // DO NOT IMPLEMENT
+ RecordLayoutBuilder(const RecordLayoutBuilder&); // DO NOT IMPLEMENT
+ void operator=(const RecordLayoutBuilder&); // DO NOT IMPLEMENT
public:
static const CXXMethodDecl *ComputeKeyFunction(const CXXRecordDecl *RD);
};
-ASTRecordLayoutBuilder::ASTRecordLayoutBuilder(ASTContext &Context)
+RecordLayoutBuilder::RecordLayoutBuilder(ASTContext &Context)
: Context(Context), Size(0), Alignment(8), Packed(false),
UnfilledBitsInLastByte(0), MaxFieldAlignment(0), DataSize(0), IsUnion(false),
NonVirtualSize(0), NonVirtualAlignment(8), PrimaryBase(0),
/// IsNearlyEmpty - Indicates when a class has a vtable pointer, but
/// no other data.
-bool ASTRecordLayoutBuilder::IsNearlyEmpty(const CXXRecordDecl *RD) const {
+bool RecordLayoutBuilder::IsNearlyEmpty(const CXXRecordDecl *RD) const {
// FIXME: Audit the corners
if (!RD->isDynamicClass())
return false;
}
void
-ASTRecordLayoutBuilder::ComputeEmptySubobjectSizes(const CXXRecordDecl *RD) {
+RecordLayoutBuilder::ComputeEmptySubobjectSizes(const CXXRecordDecl *RD) {
// Check the bases.
for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
E = RD->bases_end(); I != E; ++I) {
}
}
-void ASTRecordLayoutBuilder::IdentifyPrimaryBases(const CXXRecordDecl *RD) {
+void RecordLayoutBuilder::IdentifyPrimaryBases(const CXXRecordDecl *RD) {
const ASTRecordLayout::PrimaryBaseInfo &BaseInfo =
Context.getASTRecordLayout(RD).getPrimaryBaseInfo();
}
void
-ASTRecordLayoutBuilder::SelectPrimaryVBase(const CXXRecordDecl *RD) {
+RecordLayoutBuilder::SelectPrimaryVBase(const CXXRecordDecl *RD) {
for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
E = RD->bases_end(); I != E; ++I) {
assert(!I->getType()->isDependentType() &&
}
/// DeterminePrimaryBase - Determine the primary base of the given class.
-void ASTRecordLayoutBuilder::DeterminePrimaryBase(const CXXRecordDecl *RD) {
+void RecordLayoutBuilder::DeterminePrimaryBase(const CXXRecordDecl *RD) {
// If the class isn't dynamic, it won't have a primary base.
if (!RD->isDynamicClass())
return;
}
void
-ASTRecordLayoutBuilder::LayoutNonVirtualBases(const CXXRecordDecl *RD) {
+RecordLayoutBuilder::LayoutNonVirtualBases(const CXXRecordDecl *RD) {
// First, determine the primary base class.
DeterminePrimaryBase(RD);
}
}
-void ASTRecordLayoutBuilder::LayoutNonVirtualBase(const CXXRecordDecl *RD) {
+void RecordLayoutBuilder::LayoutNonVirtualBase(const CXXRecordDecl *RD) {
// Layout the base.
uint64_t Offset = LayoutBase(RD);
}
void
-ASTRecordLayoutBuilder::AddPrimaryVirtualBaseOffsets(const CXXRecordDecl *RD,
+RecordLayoutBuilder::AddPrimaryVirtualBaseOffsets(const CXXRecordDecl *RD,
uint64_t Offset,
const CXXRecordDecl *MostDerivedClass) {
// We already have the offset for the primary base of the most derived class.
}
void
-ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
+RecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
const CXXRecordDecl *MostDerivedClass) {
const CXXRecordDecl *PrimaryBase;
bool PrimaryBaseIsVirtual;
}
}
-void ASTRecordLayoutBuilder::LayoutVirtualBase(const CXXRecordDecl *RD) {
+void RecordLayoutBuilder::LayoutVirtualBase(const CXXRecordDecl *RD) {
// Layout the base.
uint64_t Offset = LayoutBase(RD);
assert(false && "Added same vbase offset more than once!");
}
-uint64_t ASTRecordLayoutBuilder::LayoutBase(const CXXRecordDecl *RD) {
+uint64_t RecordLayoutBuilder::LayoutBase(const CXXRecordDecl *RD) {
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
// If we have an empty base class, try to place it at offset 0.
}
bool
-ASTRecordLayoutBuilder::canPlaceRecordAtOffset(const CXXRecordDecl *RD,
+RecordLayoutBuilder::canPlaceRecordAtOffset(const CXXRecordDecl *RD,
uint64_t Offset,
bool CheckVBases) const {
// Look for an empty class with the same type at the same offset.
return true;
}
-bool ASTRecordLayoutBuilder::canPlaceFieldAtOffset(const FieldDecl *FD,
+bool RecordLayoutBuilder::canPlaceFieldAtOffset(const FieldDecl *FD,
uint64_t Offset) const {
QualType T = FD->getType();
if (const RecordType *RT = T->getAs<RecordType>()) {
return true;
}
-void ASTRecordLayoutBuilder::UpdateEmptyClassOffsets(const CXXRecordDecl *RD,
+void RecordLayoutBuilder::UpdateEmptyClassOffsets(const CXXRecordDecl *RD,
uint64_t Offset,
bool UpdateVBases) {
if (RD->isEmpty())
}
void
-ASTRecordLayoutBuilder::UpdateEmptyClassOffsets(const FieldDecl *FD,
+RecordLayoutBuilder::UpdateEmptyClassOffsets(const FieldDecl *FD,
uint64_t Offset) {
QualType T = FD->getType();
}
}
-void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) {
+void RecordLayoutBuilder::Layout(const RecordDecl *D) {
IsUnion = D->isUnion();
Packed = D->hasAttr<PackedAttr>();
#endif
}
-void ASTRecordLayoutBuilder::Layout(const ObjCInterfaceDecl *D) {
+void RecordLayoutBuilder::Layout(const ObjCInterfaceDecl *D) {
if (ObjCInterfaceDecl *SD = D->getSuperClass()) {
const ASTRecordLayout &SL = Context.getASTObjCInterfaceLayout(SD);
FinishLayout();
}
-void ASTRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
+void RecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
// Layout each field, for now, just sequentially, respecting alignment. In
// the future, this will need to be tweakable by targets.
for (RecordDecl::field_iterator Field = D->field_begin(),
LayoutField(*Field);
}
-void ASTRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize,
+void RecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize,
uint64_t TypeSize) {
assert(Context.getLangOptions().CPlusPlus &&
"Can only have wide bit-fields in C++!");
UpdateAlignment(TypeAlign);
}
-void ASTRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
+void RecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
bool FieldPacked = Packed || D->hasAttr<PackedAttr>();
uint64_t FieldOffset = IsUnion ? 0 : (DataSize - UnfilledBitsInLastByte);
uint64_t FieldSize = D->getBitWidth()->EvaluateAsInt(Context).getZExtValue();
UpdateAlignment(FieldAlign);
}
-void ASTRecordLayoutBuilder::LayoutField(const FieldDecl *D) {
+void RecordLayoutBuilder::LayoutField(const FieldDecl *D) {
if (D->isBitField()) {
LayoutBitField(D);
return;
UpdateAlignment(FieldAlign);
}
-void ASTRecordLayoutBuilder::FinishLayout() {
+void RecordLayoutBuilder::FinishLayout() {
// In C++, records cannot be of size 0.
if (Context.getLangOptions().CPlusPlus && Size == 0)
Size = 8;
Size = llvm::RoundUpToAlignment(Size, Alignment);
}
-void ASTRecordLayoutBuilder::UpdateAlignment(unsigned NewAlignment) {
+void RecordLayoutBuilder::UpdateAlignment(unsigned NewAlignment) {
if (NewAlignment <= Alignment)
return;
}
const CXXMethodDecl *
-ASTRecordLayoutBuilder::ComputeKeyFunction(const CXXRecordDecl *RD) {
+RecordLayoutBuilder::ComputeKeyFunction(const CXXRecordDecl *RD) {
assert(RD->isDynamicClass() && "Class does not have any virtual methods!");
// If a class isn't polymorphic it doesn't have a key function.
const ASTRecordLayout *NewEntry;
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
- ASTRecordLayoutBuilder Builder(*this);
+ RecordLayoutBuilder Builder(*this);
Builder.Layout(RD);
// FIXME: This is not always correct. See the part about bitfields at
Builder.PrimaryBaseIsVirtual,
Builder.Bases, Builder.VBases);
} else {
- ASTRecordLayoutBuilder Builder(*this);
+ RecordLayoutBuilder Builder(*this);
Builder.Layout(D);
NewEntry =
const CXXMethodDecl *&Entry = KeyFunctions[RD];
if (!Entry)
- Entry = ASTRecordLayoutBuilder::ComputeKeyFunction(RD);
+ Entry = RecordLayoutBuilder::ComputeKeyFunction(RD);
else
- assert(Entry == ASTRecordLayoutBuilder::ComputeKeyFunction(RD) &&
+ assert(Entry == RecordLayoutBuilder::ComputeKeyFunction(RD) &&
"Key function changed!");
return Entry;
return getObjCLayout(D, 0);
}
- ASTRecordLayoutBuilder Builder(*this);
+ RecordLayoutBuilder Builder(*this);
Builder.Layout(D);
const ASTRecordLayout *NewEntry =