This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Handle destructors in DefineOutline tweak
ClosedPublic

Authored by njames93 on Apr 7 2023, 11:49 AM.

Details

Summary

Fix destructors being incorrectly defined in the DefineOutline tweak
Currently it doesn't prepend the class name to the destructor

class A { ~A() {} };
// Destructor definition after outline
~A() {}
// After this fix
A::~A() {}

Diff Detail

Event Timeline

njames93 created this revision.Apr 7 2023, 11:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2023, 11:49 AM
Herald added a subscriber: arphaman. · View Herald Transcript
njames93 requested review of this revision.Apr 7 2023, 11:49 AM
njames93 updated this revision to Diff 511780.Apr 7 2023, 1:01 PM

Clang-format

njames93 added inline comments.Apr 13 2023, 11:09 AM
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
186–194

I had thought about adjusting the FindTarget code for this, but that resulted in a lot of other failed tests. It seems a delicate one there.

kadircet accepted this revision.Apr 14 2023, 8:06 AM

thanks!

clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
186–194

yeah it's a little unfortunate. can you have a comment about it in here so that we can keep it in mind. something like:

findExplicitReferences doesn't provide references to constructor/destructors, it only provides references to type names inside them.
this works for constructors, but doesn't work for destructor as type name doesn't cover leading `~`, so handle it specially.
This revision is now accepted and ready to land.Apr 14 2023, 8:06 AM
This revision was automatically updated to reflect the committed changes.