[PATCH] D110485: Support [[no_unique_address]] for all targets.
cqwrteur via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 28 18:33:27 PDT 2021
expnkx updated this revision to Diff 375758.
expnkx added a comment.
fixing clang format
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110485/new/
https://reviews.llvm.org/D110485
Files:
clang/lib/AST/RecordLayoutBuilder.cpp
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,12 +2923,17 @@
ElementInfo Info = getAdjustedElementInfo(FD);
Alignment = std::max(Alignment, Info.Alignment);
CharUnits FieldOffset;
+ auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+ bool PotentiallyOverlapping =
+ FD->hasAttr<NoUniqueAddressAttr>() && FieldClass;
+ bool IsOverlappingEmptyField =
+ PotentiallyOverlapping && FieldClass->isEmpty();
if (UseExternalLayout)
FieldOffset =
Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
- else if (IsUnion)
+ else if (IsUnion || IsOverlappingEmptyField) {
FieldOffset = CharUnits::Zero();
- else
+ } else
FieldOffset = Size.alignTo(Info.Alignment);
placeFieldAtOffset(FieldOffset);
Size = std::max(Size, FieldOffset + Info.Size);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110485.375758.patch
Type: text/x-patch
Size: 971 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210929/c34a7ace/attachment-0001.bin>
More information about the cfe-commits
mailing list