Removes the static token when defining a function out of line if the function is a CXXMethodDecl
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
thanks for the patch!
this is quite similar to handling kw_virtual even handling multiple static keywords. Could you rather factor the search for kw, generate an edit to delete specifier part into a DelKeyword lambda similar to DelAttr and call it with kw_static and kw_virtual?
p.s. you can make use of tok::getKeywordSpelling for error messages.
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp | ||
---|---|---|
242–245 | nit, AllowMultiple is always false(see my comment below) maybe just drop that parameter and add a comment to lambda saying that it deletes all occurences of the keyword in range. | |
242–245 | nit: s/DeleteKeyword/DelKeyword/ to be consistent with DelAttr | |
247 | this condition becomes obsolete once you get rid of AllowMultiple. | |
255 | llvm::formatv("define outline: couldn't remove `{0}` keyword.", tok::getKeywordSpelling(Kind)) | |
265 | nit: put braces here as statement spans multiple lines | |
284 | please use formatv here as well, while dropping can't move outline | |
289 | nit: this also needs to be a methoddecl, so you can combine the two checks: if(const auto *MD = dyn_cast<CXXMethodDecl>(FD)) { if(MD->isvirt...) delKeyword(virt); if(MD->isStatic) delKeyword(static); } | |
293 | sorry if I miscommunicated, I was trying to say that multiple static keywords are also allowed by clang. So we should be dropping all of them, as we do for virtual | |
clang-tools-extra/clangd/unittests/TweakTests.cpp | ||
2152 | please also add a test with multiple static keywords |
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp | ||
---|---|---|
293 | Yeah sorry, I checked and it was rejected. I just realised I was checking against gcc... |
nit, AllowMultiple is always false(see my comment below) maybe just drop that parameter and add a comment to lambda saying that it deletes all occurences of the keyword in range.