[clang] Implement [[msvc::no_unique_address]] (PR #65675)
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 7 15:02:29 PDT 2023
================
@@ -2937,14 +2964,97 @@ void MicrosoftRecordLayoutBuilder::layoutNonVirtualBase(
BaseOffset = CharUnits::Zero();
} else {
// Otherwise, lay the base out at the end of the MDC.
- BaseOffset = Size = Size.alignTo(Info.Alignment);
+ BaseOffset = DataSize = Size = Size.alignTo(Info.Alignment);
}
+
+ // Place in EmptySubobjects map but don't check the position? MSVC seems to
+ // not allow fields to overlap at the end of a virtual base, but they can
+ // overlap with other bass.
+ EmptySubobjects->CanPlaceBaseAtOffset(Base, BaseOffset);
}
+
Bases.insert(std::make_pair(BaseDecl, BaseOffset));
Size += BaseLayout.getNonVirtualSize();
+ DataSize = Size;
PreviousBaseLayout = &BaseLayout;
}
+BaseSubobjectInfo *MicrosoftRecordLayoutBuilder::computeBaseSubobjectInfo(
+ const CXXRecordDecl *RD, bool IsVirtual, BaseSubobjectInfo *Derived) {
+ // This is copied directly from ItaniumRecordLayoutBuilder::ComputeBaseSubobjectInfo.
----------------
rnk wrote:
Can we structure this in a way that avoids the duplication?
https://github.com/llvm/llvm-project/pull/65675
More information about the cfe-commits
mailing list