public:
/// PrimaryBaseInfo - Contains info about a primary base.
struct PrimaryBaseInfo {
- PrimaryBaseInfo() : Base(0), IsVirtual(false) {}
+ PrimaryBaseInfo() {}
PrimaryBaseInfo(const CXXRecordDecl *Base, bool IsVirtual)
- : Base(Base), IsVirtual(IsVirtual) {}
+ : Value(Base, IsVirtual) {}
- /// Base - The primary base.
- const CXXRecordDecl *Base;
+ /// Value - Points to the primary base. The single-bit value
+ /// will be non-zero when the primary base is virtual.
+ llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> Value;
+
+ /// getBase - Returns the primary base.
+ const CXXRecordDecl *getBase() const { return Value.getPointer(); }
- /// IsVirtual - Whether the primary base is virtual or not.
- bool IsVirtual;
+ /// isVirtual - Returns whether the primary base is virtual or not.
+ bool isVirtual() const { return Value.getInt(); }
};
private:
// FIXME: Migrate off of this function and use getPrimaryBaseInfo directly.
const CXXRecordDecl *getPrimaryBase() const {
- return getPrimaryBaseInfo().Base;
+ return getPrimaryBaseInfo().getBase();
}
// FIXME: Migrate off of this function and use getPrimaryBaseInfo directly.
bool getPrimaryBaseWasVirtual() const {
- return getPrimaryBaseInfo().IsVirtual;
+ return getPrimaryBaseInfo().isVirtual();
}
/// getBaseClassOffset - Get the offset, in bits, for the given base class.
}
SelectPrimaryBase(RD);
- if (!PrimaryBase.Base) {
+ if (!PrimaryBase.getBase()) {
int AS = 0;
UpdateAlignment(Ctx.Target.getPointerAlign(AS));
Size += Ctx.Target.getPointerWidth(AS);
const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
// Skip the PrimaryBase here, as it is laid down first.
- if (Base != PrimaryBase.Base || PrimaryBase.IsVirtual)
+ if (Base != PrimaryBase.getBase() || PrimaryBase.isVirtual())
LayoutBaseNonVirtually(Base, false);
}
}
// If the record has a primary base class that is virtual, add it to the set
// of primary bases.
- if (BaseInfo.IsVirtual)
- IndirectPrimaryBases.insert(BaseInfo.Base);
+ if (BaseInfo.isVirtual())
+ IndirectPrimaryBases.insert(BaseInfo.getBase());
// Now traverse all bases and find primary bases for them.
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (!i->isVirtual()) {
SelectPrimaryVBase(Base, FirstPrimary);
- if (PrimaryBase.Base)
+ if (PrimaryBase.getBase())
return;
continue;
}
// Otherwise if is the first nearly empty virtual base, if one exists,
// otherwise there is no primary base class.
- if (!PrimaryBase.Base)
+ if (!PrimaryBase.getBase())
setPrimaryBase(FirstPrimary, /*IsVirtual=*/true);
}
if (Base->getNumVBases()) {
const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(Base);
- const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBaseInfo().Base;
+ const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBaseInfo().getBase();
LayoutVirtualBases(Class, Base, PrimaryBase, BaseOffset, mark,
IndirectPrimary);
}
if (RD) {
LayoutVtable(RD);
// PrimaryBase goes first.
- if (PrimaryBase.Base) {
- if (PrimaryBase.IsVirtual)
- IndirectPrimaryBases.insert(PrimaryBase.Base);
- LayoutBaseNonVirtually(PrimaryBase.Base, PrimaryBase.IsVirtual);
+ if (PrimaryBase.getBase()) {
+ if (PrimaryBase.isVirtual())
+ IndirectPrimaryBases.insert(PrimaryBase.getBase());
+ LayoutBaseNonVirtually(PrimaryBase.getBase(), PrimaryBase.isVirtual());
}
LayoutNonVirtualBases(RD);
}
if (RD) {
llvm::SmallSet<const CXXRecordDecl*, 32> mark;
- LayoutVirtualBases(RD, RD, PrimaryBase.Base, 0, mark, IndirectPrimaryBases);
+ LayoutVirtualBases(RD, RD, PrimaryBase.getBase(),
+ 0, mark, IndirectPrimaryBases);
}
// Finally, round the size of the total struct up to the alignment of the