[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 03:09:51 PDT 2019


ilya-biryukov added a comment.

Just a few final NITs from my side. 
And would also be nice to get tests with macros.



================
Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:251
+    }
+    NewName.append(SourceParam->getName());
+    ParamToNewName[DestParam->getCanonicalDecl()] = std::move(NewName);
----------------
NIT: maybe use assignment syntax?
 `NewName += SourceParam->getName()`


================
Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:270
+  for (size_t I = 0, E = Dest->param_size(); I != E; ++I)
+    HandleParam(Dest->getParamDecl(I), Source->getParamDecl(I));
+
----------------
NIT: also add `assert(Source->param_size() == Dest->param_size())`?


================
Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:275
+  const LangOptions &LangOpts = Dest->getASTContext().getLangOpts();
+  // Collect other references in function signautre, i.e parameter types and
+  // default arguments.
----------------
s/signautre/signature


================
Comment at: clang-tools-extra/clangd/unittests/TweakTests.cpp:1492
 
+TEST_F(DefineInlineTest, TransformParamNames) {
+  EXPECT_EQ(apply(R"cpp(
----------------
Could you add tests with some parameter references inside macro expansions?
To make sure we don't crash and don't produce invalid edits? Failing is obviously ok


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