forked from OSchip/llvm-project
Make EmptySubobjectMap::CanPlaceBaseAtOffset take a BaseSubobjectInfo as well.
llvm-svn: 105113
This commit is contained in:
parent
d7f3fcf248
commit
a60b86a3fa
|
@ -103,8 +103,7 @@ public:
|
||||||
/// at the given offset.
|
/// at the given offset.
|
||||||
/// Returns false if placing the record will result in two components
|
/// Returns false if placing the record will result in two components
|
||||||
/// (direct or indirect) of the same type having the same offset.
|
/// (direct or indirect) of the same type having the same offset.
|
||||||
bool CanPlaceBaseAtOffset(const CXXRecordDecl *RD, bool BaseIsVirtual,
|
bool CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info, uint64_t Offset);
|
||||||
uint64_t Offset);
|
|
||||||
|
|
||||||
/// CanPlaceFieldAtOffset - Return whether a field can be placed at the given
|
/// CanPlaceFieldAtOffset - Return whether a field can be placed at the given
|
||||||
/// offset.
|
/// offset.
|
||||||
|
@ -274,8 +273,7 @@ void EmptySubobjectMap::UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmptySubobjectMap::CanPlaceBaseAtOffset(const CXXRecordDecl *RD,
|
bool EmptySubobjectMap::CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info,
|
||||||
bool BaseIsVirtual,
|
|
||||||
uint64_t Offset) {
|
uint64_t Offset) {
|
||||||
// If we know this class doesn't have any empty subobjects we don't need to
|
// If we know this class doesn't have any empty subobjects we don't need to
|
||||||
// bother checking.
|
// bother checking.
|
||||||
|
@ -283,21 +281,12 @@ bool EmptySubobjectMap::CanPlaceBaseAtOffset(const CXXRecordDecl *RD,
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// FIXME: Re-enable this.
|
// FIXME: Re-enable this.
|
||||||
#if 0
|
|
||||||
BaseSubobjectInfo *Info;
|
|
||||||
|
|
||||||
if (BaseIsVirtual)
|
|
||||||
Info = VirtualBaseInfo.lookup(RD);
|
|
||||||
else
|
|
||||||
Info = NonVirtualBaseInfo.lookup(RD);
|
|
||||||
|
|
||||||
if (!CanPlaceBaseSubobjectAtOffset(Info, Offset))
|
if (!CanPlaceBaseSubobjectAtOffset(Info, Offset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// We are able to place the base at this offset. Make sure to update the
|
// We are able to place the base at this offset. Make sure to update the
|
||||||
// empty base subobject map.
|
// empty base subobject map.
|
||||||
UpdateEmptyBaseSubobjects(Info, Offset);
|
UpdateEmptyBaseSubobjects(Info, Offset);
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,7 +1021,7 @@ uint64_t RecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
|
||||||
|
|
||||||
// If we have an empty base class, try to place it at offset 0.
|
// If we have an empty base class, try to place it at offset 0.
|
||||||
if (Base->Class->isEmpty() &&
|
if (Base->Class->isEmpty() &&
|
||||||
EmptySubobjects->CanPlaceBaseAtOffset(Base->Class, Base->IsVirtual, 0) &&
|
EmptySubobjects->CanPlaceBaseAtOffset(Base, 0) &&
|
||||||
canPlaceRecordAtOffset(Base->Class, 0, /*CheckVBases=*/false)) {
|
canPlaceRecordAtOffset(Base->Class, 0, /*CheckVBases=*/false)) {
|
||||||
// We were able to place the class at offset 0.
|
// We were able to place the class at offset 0.
|
||||||
UpdateEmptyClassOffsets(Base->Class, 0, /*UpdateVBases=*/false);
|
UpdateEmptyClassOffsets(Base->Class, 0, /*UpdateVBases=*/false);
|
||||||
|
@ -1049,8 +1038,7 @@ uint64_t RecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
|
||||||
|
|
||||||
// Try to place the base.
|
// Try to place the base.
|
||||||
while (true) {
|
while (true) {
|
||||||
if (EmptySubobjects->CanPlaceBaseAtOffset(Base->Class, Base->IsVirtual,
|
if (EmptySubobjects->CanPlaceBaseAtOffset(Base, Offset) &&
|
||||||
Offset) &&
|
|
||||||
canPlaceRecordAtOffset(Base->Class, Offset, /*CheckVBases=*/false))
|
canPlaceRecordAtOffset(Base->Class, Offset, /*CheckVBases=*/false))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue