summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/change-namespace/ChangeNamespace.cpp
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
commit284b97c6bcc91184c327b75d3837100abdd0dc0d (patch)
treea627fa2560d49795341ce3987cfe417cace8ba4d /clang-tools-extra/change-namespace/ChangeNamespace.cpp
parent89b1f94e64e678f19f1e832fdd00de1ece946c9f (diff)
downloadbcm5719-llvm-284b97c6bcc91184c327b75d3837100abdd0dc0d.tar.gz
bcm5719-llvm-284b97c6bcc91184c327b75d3837100abdd0dc0d.zip
[change-namespace] do not rename specialized template parameters.
Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31076 llvm-svn: 298090
Diffstat (limited to 'clang-tools-extra/change-namespace/ChangeNamespace.cpp')
-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
OpenPOWER on IntegriCloud