This is an archive of the discontinued LLVM Phabricator instance.

[C++4OpenCL] Fix missing address space on implicit move assignment operator
ClosedPublic

Authored by olestrohm on May 27 2021, 7:36 AM.

Details

Summary

This fixes the missing address space on this in the implicit move assignment operator.
The function called here is an abstraction around the lines that have been removed, and also sets the address space correctly.
This is copied from CopyConstructor, CopyAssignment and MoveConstructor, all of which use this new function, and now
MoveAssignment is has been aligned to use the same method.

I also added a new test file to check the output AST. If there's a better place for this test I will move it there.

Fixes: PR50259

Diff Detail

Event Timeline

olestrohm created this revision.May 27 2021, 7:36 AM
olestrohm requested review of this revision.May 27 2021, 7:36 AM
svenvh added a comment.Jun 1 2021, 3:59 AM

I also added a new test file to check the output AST. If there's a better place for this test I will move it there.

If you're primarily interested in the AST, then it doesn't have to be a Sema test I guess. In that case clang/test/AST seems to be a better place, and you could also remove the -verify parts of the test perhaps (unless you think it adds value that isn't tested elsewhere)?

clang/test/SemaOpenCLCXX/addrspace-assignment.clcpp
10

Maybe rename this struct to avoid any potential confusion with the implicit keyword in the dumps above? Even something as simple as S should do I think.

olestrohm updated this revision to Diff 348969.Jun 1 2021, 7:21 AM

Cleaned up the test by renaming the struct and making the test compile.

The test has also been moved to clang/test/AST as suggested, since it really
just makes sure that the generated AST contains the correct implicit methods.

svenvh accepted this revision.Jun 1 2021, 7:47 AM

LGTM!

This revision is now accepted and ready to land.Jun 1 2021, 7:47 AM
abhinavgaba added inline comments.
clang/test/AST/ast-dump-implicit-members.clcpp
10 ↗(On Diff #350200)

Could you please relax these checks? The test fails with -triple i386-pc-win32 with errors like this:

ast-dump-implicit-members.clcpp:10:11: error: CHECK: expected string not found in input
// CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () __generic noexcept'
          ^
<stdin>:1:1: note: scanning from here
Dumping __NSConstantString:
^
<stdin>:16:18: note: possible intended match here
|-CXXConstructorDecl 0x10b6c718 <col:8> col:8 implicit used constexpr S 'void () __attribute__((thiscall)) __generic noexcept' inline default trivial
                 ^
olestrohm added inline comments.Jun 10 2021, 2:45 AM
clang/test/AST/ast-dump-implicit-members.clcpp
10 ↗(On Diff #350200)

Hi, sorry for this.
I have relaxed the tests in rGac677e69bdfc, so hopefully that should fix it.

abhinavgaba added inline comments.Jun 10 2021, 10:29 AM
clang/test/AST/ast-dump-implicit-members.clcpp
10 ↗(On Diff #350200)

Thanks for the fix, @olestrohm.