This is an archive of the discontinued LLVM Phabricator instance.

[Clangd] Fix the code action `RemoveUsingNamespace`
ClosedPublic

Authored by v1nh1shungry on Nov 5 2022, 9:56 AM.

Details

Summary

Avoid adding qualifiers before C++ operators declared in a non-class context

Diff Detail

Event Timeline

v1nh1shungry created this revision.Nov 5 2022, 9:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 5 2022, 9:56 AM
v1nh1shungry requested review of this revision.Nov 5 2022, 9:56 AM
tom-anders requested changes to this revision.Nov 5 2022, 11:47 AM

Did a quick test on my machine, seems to work! Can you add a regression test to clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp though?

This revision now requires changes to proceed.Nov 5 2022, 11:47 AM

Add a test and rewrite the comment

Correct the test

@tom-anders Thank you for reviewing!

I tried adding a test but I don't know how to run the tests.

And I just found that operators declared in a class context are already handled in the existing version, but user-defined literals are not, so I rewrote the comments.

Correct the test

@tom-anders Thank you for reviewing!

I tried adding a test but I don't know how to run the tests.

And I just found that operators declared in a class context are already handled in the existing version, but user-defined literals are not, so I rewrote the comments.

I guess that's ninja check-clangd?

clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
259

is this a typo?

@tom-anders Thank you for reviewing!

I tried adding a test but I don't know how to run the tests.

And I just found that operators declared in a class context are already handled in the existing version, but user-defined literals are not, so I rewrote the comments.

Sorry, I found tips about running tests in the document. Feel like a fool :)

Please check this test is correct and suitable. Thanks!

v1nh1shungry added inline comments.Nov 5 2022, 8:23 PM
clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
259

I guess not. I refer to the tests above and I think this represents the cursor. But I'm not sure though.

junaire added inline comments.Nov 5 2022, 8:56 PM
clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
259

I guess not. I refer to the tests above and I think this represents the cursor. But I'm not sure though.

OK, thanks for the clarification!

@junaire Thank you for reviewing!

Format codes

nridge added a subscriber: nridge.Nov 6 2022, 12:47 AM
tom-anders accepted this revision.Nov 6 2022, 1:15 AM

Thanks for the fix, LGTM! Do you want me to commit this for you?

This revision is now accepted and ready to land.Nov 6 2022, 1:15 AM

Thanks for the fix, LGTM! Do you want me to commit this for you?

Yes! Thanks a lot!

This revision was automatically updated to reflect the committed changes.