[PATCH] D110485: Support [[no_unique_address]] for all targets.

cqwrteur via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 28 13:50:57 PDT 2021


expnkx updated this revision to Diff 375690.
expnkx added a comment.

I cannot find out where to add attribute that starts with msvc::xxxxx.

I am just applying this "potential" patch to the clang upstream. In the future we can just remove TargetItaniumCXXABI attr in the clang table gen file without worrying about too much. So it is a "noop".

So this patch changes nothing but it makes us be convenient to fix it in the future.


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
@@ -2919,6 +2919,10 @@
     layoutBitField(FD);
     return;
   }
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping = FD->hasAttr<NoUniqueAddressAttr>() && FieldClass;
+  bool IsOverlappingEmptyField =
+      PotentiallyOverlapping && FieldClass->isEmpty();
   LastFieldIsNonZeroWidthBitfield = false;
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
@@ -2926,7 +2930,7 @@
   if (UseExternalLayout)
     FieldOffset =
         Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
     FieldOffset = CharUnits::Zero();
   else
     FieldOffset = Size.alignTo(Info.Alignment);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110485.375690.patch
Type: text/x-patch
Size: 947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210928/bf7e54e3/attachment.bin>


More information about the cfe-commits mailing list