summaryrefslogtreecommitdiff
path: root/clang-tools-extra/change-namespace
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2017-03-17 14:05:39 +0000
committerEric Liu <ioeric@google.com>2017-03-17 14:05:39 +0000
commit1661353f2f9593c8e9e06631b04443d7c6281111 (patch)
tree125a761a559216e6f8503794e9376d28648934ca /clang-tools-extra/change-namespace
parentd1a423a2c4b1455e741e69ba98b02e77c349dcfe (diff)
[change-namespace] do not rename specialized template parameters.
Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31076
Diffstat (limited to 'clang-tools-extra/change-namespace')
-rw-r--r--clang-tools-extra/change-namespace/ChangeNamespace.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang-tools-extra/change-namespace/ChangeNamespace.cpp b/clang-tools-extra/change-namespace/ChangeNamespace.cpp
index 36f04243ce8..e07066794b5 100644
--- a/clang-tools-extra/change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/change-namespace/ChangeNamespace.cpp
@@ -286,6 +286,15 @@ AST_MATCHER(EnumDecl, isScoped) {
return Node.isScoped();
}
+bool isTemplateParameter(TypeLoc Type) {
+ while (!Type.isNull()) {
+ if (Type.getTypeLocClass() == TypeLoc::SubstTemplateTypeParm)
+ return true;
+ Type = Type.getNextTypeLoc();
+ }
+ return false;
+}
+
} // anonymous namespace
ChangeNamespaceTool::ChangeNamespaceTool(
@@ -833,6 +842,8 @@ void ChangeNamespaceTool::fixTypeLoc(
// Types of CXXCtorInitializers do not need to be fixed.
if (llvm::is_contained(BaseCtorInitializerTypeLocs, Type))
return;
+ if (isTemplateParameter(Type))
+ return;
// The declaration which this TypeLoc refers to.
const auto *FromDecl = Result.Nodes.getNodeAs<NamedDecl>("from_decl");
// `hasDeclaration` gives underlying declaration, but if the type is