[PATCH] D114732: [clang] Mark `trivial_abi` types as "trivially relocatable".

Devin Jeanpierre via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 19 13:09:59 PST 2022


devin.jeanpierre added a comment.

Sorry, I missed your other comments. Let me know if there's anything else I didn't address.



================
Comment at: clang/test/SemaCXX/attr-trivial-abi.cpp:146
+#ifdef _WIN32
+static_assert(!__is_trivially_relocatable(CopyDeleted), "");
+#else
----------------
Quuxplusone wrote:
> I think you meant `s/CopyDeleted/S20/` here.
Ugh, copy-paste. Thanks, done.


================
Comment at: clang/test/SemaCXX/type-traits.cpp:2862
+static_assert(__is_trivially_relocatable(int), "");
+static_assert(__is_trivially_relocatable(int[]), "");
+
----------------
Quuxplusone wrote:
> It's mildly surprising that an incomplete type can be trivially relocatable; but it doesn't really matter, since nobody can be depending on this answer. (`int[]` is not movable or destructible, so it's not relocatable — never mind //trivially// relocatable.)
I think it is consistent with the other type traits in C++ -- for example, this assert would also pass:

```
static_assert(std::is_trivially_copyable_v<int[]>, "");
```

The important thing is that this line fails to compile:

```
struct Incomplete;
bool unused = __is_trivially_relocatable(Incomplete);
```


================
Comment at: clang/test/SemaObjCXX/objc-weak-type-traits.mm:213-214
+// __is_trivially_relocatable
+TRAIT_IS_TRUE(__is_trivially_relocatable, __strong id);
+TRAIT_IS_FALSE(__is_trivially_relocatable, __weak id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __autoreleasing id);
----------------
Quuxplusone wrote:
> IIUC (which I probably don't): Both `__strong id` and `__weak id` //are// trivially relocatable in the p1144 sense, but only `__strong id` is trivial-for-purposes-of-ABI, and that's why only `__strong id` is being caught here. Yes/no?
`__weak` can't be trivially relocatable in any proposal, because their address is registered in a runtime table, so that they can be nulled out when the object is deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114732



More information about the cfe-commits mailing list