[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 16 14:35:58 PST 2020
ahatanak added inline comments.
================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+ // except that it has a non-trivial member *with* the trivial_abi attribute.
+ for (auto Base : D->bases()) {
+ if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())
----------------
It looks like this patch changes the way `D` is passed in the following code:
```
struct B {
int i[4];
B();
B(const B &) = default;
B(B &&);
};
struct D : B {
D();
D(const D &) = default;
D(D &&) = delete;
};
void testB(B a);
void testD(D a);
void testCallB() {
B b;
testB(b);
}
void testCallD() {
D d;
testD(d);
}
```
`B` cannot be passed in registers because it has a non-trivial move constructor, whereas `D` can be passed in registers because the move constructor is deleted and the copy constructor is trivial.
I'm not sure what the best way to handle this is, but I just wanted to point this out.
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