[PATCH] D22853: [clang-rename] add support for template parameter renaming

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 1 10:16:05 PDT 2016


alexfh requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: clang-rename/USRFinder.cpp:80
@@ -79,1 +79,3 @@
         TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+    if (const auto *TemplateTypeParm = dyn_cast<TemplateTypeParmType>(Loc.getType())) {
+      return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
----------------
It's not common to use braces around single-line `if` bodies in LLVM/Clang code.

================
Comment at: clang-rename/USRLocFinder.cpp:104
@@ -103,1 +103,3 @@
     }
+    if (const auto TemplateTypeParm = dyn_cast<TemplateTypeParmType>(Loc.getType())) {
+      if (getUSRForDecl(TemplateTypeParm->getDecl()) == USR) {
----------------
nit: `const auto *`

================
Comment at: test/clang-rename/TemplateTypenameFindByTemplateParam.cpp:1
@@ -1,8 +1,2 @@
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=270 -new-name=U %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename template parameters correctly.
-// XFAIL: *
+// RUN: clang-rename -offset=87 -new-name=Bar %s -- | FileCheck %s
 
----------------
As noted elsewhere, this way of testing is wrong.

================
Comment at: test/clang-rename/TemplateTypenameFindByTypeInside.cpp:1
@@ -1,6 +1,2 @@
-// RUN: clang-rename -offset=289 -new-name=U %s -- | FileCheck %s
-
-// Currently unsupported test.
-// FIXME: clang-rename should be able to rename template parameters correctly.
-// XFAIL: *
+// RUN: clang-rename -offset=153 -new-name=Bar %s -- | FileCheck %s
 
----------------
ditto


https://reviews.llvm.org/D22853





More information about the cfe-commits mailing list