From 284b97c6bcc91184c327b75d3837100abdd0dc0d Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Fri, 17 Mar 2017 14:05:39 +0000 Subject: [change-namespace] do not rename specialized template parameters. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31076 llvm-svn: 298090 --- clang-tools-extra/change-namespace/ChangeNamespace.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'clang-tools-extra/change-namespace/ChangeNamespace.cpp') 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("from_decl"); // `hasDeclaration` gives underlying declaration, but if the type is -- cgit v1.2.3