[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 16 02:43:39 PDT 2019
ilya-biryukov added a comment.
An alternative approach I'm thinking of:
After D68977 <https://reviews.llvm.org/D68977> lands, we could try using `findExplicitReferences` to produce all of these edits:
1. we collect locations of all references and declaration of relevant parameters and template parameters.
2. find the ones where the name differs and produce the changes.
That would handle not only references in the default argument, but also all references in the body and should be less code overall.
IMO it's worth exploring this approach right away, e.g. you could layer your patch on top of the current version of D68977 <https://reviews.llvm.org/D68977>
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:229
+/// Generates a replacement that renames \p Dest to \p Source.
+llvm::Error rewriteParameterName(tooling::Replacements &Replacements,
----------------
We only need name from the `Source`. Why not accept it as a `StringRef Name` directly?
Would allow to call this function even if `Source` is not a `NamedDecl`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68937/new/
https://reviews.llvm.org/D68937
More information about the cfe-commits
mailing list