[clang-rename] add support for template parameter renaming
Few simple tweaks allow template parameters to be renamed. See
TemplateTypenameFindBy{TemplateParam|TypeInside}.cpp
Reviewers: alexfh
Differential Revision: https://reviews.llvm.org/D22853
llvm-svn: 277437
diff --git a/clang-tools-extra/clang-rename/USRFinder.cpp b/clang-tools-extra/clang-rename/USRFinder.cpp
index 7f26945..2589be1 100644
--- a/clang-tools-extra/clang-rename/USRFinder.cpp
+++ b/clang-tools-extra/clang-rename/USRFinder.cpp
@@ -77,6 +77,10 @@
const auto TypeBeginLoc = Loc.getBeginLoc();
const auto TypeEndLoc = Lexer::getLocForEndOfToken(
TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+ if (const auto *TemplateTypeParm =
+ dyn_cast<TemplateTypeParmType>(Loc.getType())) {
+ return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
+ }
return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
TypeEndLoc);
}