summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-move
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2017-01-17 10:08:11 +0000
committerHaojian Wu <hokein@google.com>2017-01-17 10:08:11 +0000
commitb3d988844993168704954b4d34d87b9f34a1ab1d (patch)
tree365043ded482cb9cba4d9d5090e7fc8c287b7f31 /clang-tools-extra/clang-move
parent9778921a0b3145003a091ffd6b030c81f7dccc97 (diff)
downloadbcm5719-llvm-b3d988844993168704954b4d34d87b9f34a1ab1d.tar.gz
bcm5719-llvm-b3d988844993168704954b4d34d87b9f34a1ab1d.zip
[clang-move] Ignore using decls which are defined in macros.
Summary: Also ignore helpers which are defined in macro. Currently clang-move doesn't handle macro well enough, especiall for complex macros. This patch will ignore declarations in macros to make the behavior of clang-move more correct. Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28774 llvm-svn: 292207
Diffstat (limited to 'clang-tools-extra/clang-move')
-rw-r--r--clang-tools-extra/clang-move/ClangMove.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/clang-tools-extra/clang-move/ClangMove.cpp b/clang-tools-extra/clang-move/ClangMove.cpp
index be3fca0dff5..e1f20b70009 100644
--- a/clang-tools-extra/clang-move/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/ClangMove.cpp
@@ -31,6 +31,8 @@ namespace {
// FIXME: Move to ASTMatchers.
AST_MATCHER(VarDecl, isStaticDataMember) { return Node.isStaticDataMember(); }
+AST_MATCHER(NamedDecl, notInMacro) { return !Node.getLocation().isMacroID(); }
+
AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
ast_matchers::internal::Matcher<Decl>, InnerMatcher) {
const auto *Context = Node.getDeclContext();
@@ -525,12 +527,12 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
// Matching using decls/type alias decls which are in named/anonymous/global
// namespace, these decls are always copied to new.h/cc. Those in classes,
// functions are covered in other matchers.
- Finder->addMatcher(
- namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl),
- usingDirectiveDecl(IsOldCCTopLevelDecl),
- typeAliasDecl(IsOldCCTopLevelDecl)))
- .bind("using_decl"),
- this);
+ Finder->addMatcher(namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl),
+ usingDirectiveDecl(IsOldCCTopLevelDecl),
+ typeAliasDecl(IsOldCCTopLevelDecl)),
+ notInMacro())
+ .bind("using_decl"),
+ this);
// Match static functions/variable definitions which are defined in named
// namespaces.
@@ -556,9 +558,11 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
allOf(DefinitionInOldCC, anyOf(isStaticStorageClass(), InAnonymousNS));
// Match helper classes separately with helper functions/variables since we
// want to reuse these matchers in finding helpers usage below.
- auto HelperFuncOrVar = namedDecl(anyOf(functionDecl(IsOldCCHelperDefinition),
- varDecl(IsOldCCHelperDefinition)));
- auto HelperClasses = cxxRecordDecl(DefinitionInOldCC, InAnonymousNS);
+ auto HelperFuncOrVar =
+ namedDecl(notInMacro(), anyOf(functionDecl(IsOldCCHelperDefinition),
+ varDecl(IsOldCCHelperDefinition)));
+ auto HelperClasses =
+ cxxRecordDecl(notInMacro(), DefinitionInOldCC, InAnonymousNS);
// Save all helper declarations in old.cc.
Finder->addMatcher(
namedDecl(anyOf(HelperFuncOrVar, HelperClasses)).bind("helper_decls"),
OpenPOWER on IntegriCloud