[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

Zoe Carver via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 09:55:50 PST 2020


zoecarver added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6416
+  if (D->hasAttr<TrivialABIAttr>())
+    return true;
+
----------------
rjmccall wrote:
> zoecarver wrote:
> > rjmccall wrote:
> > > I don't think we can just unconditionally check for the attribute.  The rule for `trivial_abi` is that it overrides direct sources of non-triviality, but if there's a subobject which can't be safely passed in registers, we'll still pass aggregates indirectly.  This means we can safely add the attribute whenever a class's own special members don't rely on non-triviality without having to recursively check the component types.
> > If there's a non-trivial field (or base) then the attribute won't be applied and a warning will be emitted. See the below tests (though, it would probably be good to add some more).
> Do we just remove it without a warning in template instantiation?  At any rate, if we're relying on the attribute not being present when it isn't authoritative, we should say that here.
Alright. I'll put a comment. 

> Do we just remove it without a warning in template instantiation?

[[ https://godbolt.org/z/8Ex936 | That would appear to be what happens. ]]


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92361/new/

https://reviews.llvm.org/D92361



More information about the cfe-commits mailing list