From 03c8963c3222012edad578d5d114f8051ff15990 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 2 May 2017 12:15:11 +0000 Subject: [clang-move] Find template class forward declarations more precisely. Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D32741 llvm-svn: 301914 --- clang-tools-extra/clang-move/ClangMove.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'clang-tools-extra/clang-move/ClangMove.cpp') diff --git a/clang-tools-extra/clang-move/ClangMove.cpp b/clang-tools-extra/clang-move/ClangMove.cpp index 8dbeaead097..3a44aa3e9da 100644 --- a/clang-tools-extra/clang-move/ClangMove.cpp +++ b/clang-tools-extra/clang-move/ClangMove.cpp @@ -504,8 +504,11 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) { isExpansionInFile(makeAbsolutePath(Context->Spec.OldHeader)); auto InOldCC = isExpansionInFile(makeAbsolutePath(Context->Spec.OldCC)); auto InOldFiles = anyOf(InOldHeader, InOldCC); - auto ForwardDecls = - cxxRecordDecl(unless(anyOf(isImplicit(), isDefinition()))); + auto classTemplateForwardDecls = + classTemplateDecl(unless(has(cxxRecordDecl(isDefinition())))); + auto ForwardClassDecls = namedDecl( + anyOf(cxxRecordDecl(unless(anyOf(isImplicit(), isDefinition()))), + classTemplateForwardDecls)); auto TopLevelDecl = hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl())); @@ -518,9 +521,8 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) { // We consider declarations inside a class belongs to the class. So these // declarations will be ignored. auto AllDeclsInHeader = namedDecl( - unless(ForwardDecls), unless(namespaceDecl()), - unless(usingDirectiveDecl()), // using namespace decl. - unless(classTemplateDecl(has(ForwardDecls))), // template forward decl. + unless(ForwardClassDecls), unless(namespaceDecl()), + unless(usingDirectiveDecl()), // using namespace decl. InOldHeader, hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl()))), hasDeclContext(decl(anyOf(namespaceDecl(), translationUnitDecl())))); @@ -531,7 +533,7 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) { return; // Match forward declarations in old header. - Finder->addMatcher(namedDecl(ForwardDecls, InOldHeader).bind("fwd_decl"), + Finder->addMatcher(namedDecl(ForwardClassDecls, InOldHeader).bind("fwd_decl"), this); //============================================================================ -- cgit v1.2.3