[clang] Implement [[msvc::no_unique_address]] (PR #65675)
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 7 14:45:52 PDT 2023
================
@@ -4505,6 +4505,14 @@ bool FieldDecl::isZeroSize(const ASTContext &Ctx) const {
if (!CXXRD->isEmpty())
return false;
+ // MS ABI: nonzero if class type with class type fields
+ if (Ctx.getTargetInfo().getCXXABI().isMicrosoft() &&
+ llvm::any_of(CXXRD->fields(), [](const FieldDecl *Field) {
+ return Field->getType()->getAs<RecordType>();
+ })) {
+ return false;
+ }
+
// Otherwise, [...] the circumstances under which the object has zero size
// are implementation-defined.
// FIXME: This might be Itanium ABI specific; we don't yet know what the MS
----------------
rnk wrote:
I think you've addressed this FIXME. Perhaps you can early return true if !MS ABI, and then return a result based on the any_of check.
https://github.com/llvm/llvm-project/pull/65675
More information about the cfe-commits
mailing list