Index: clang-move/ClangMove.cpp =================================================================== --- clang-move/ClangMove.cpp +++ clang-move/ClangMove.cpp @@ -351,20 +351,22 @@ .bind("class_static_var_decl"), this); - auto inAnonymousNamespace = hasParent(namespaceDecl(isAnonymous())); - // Match functions/variables definitions which are defined in anonymous - // namespace in old cc. + auto InAnonymousNamespace = hasParent(namespaceDecl(isAnonymous())); Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())), - inAnonymousNamespace) - .bind("decls_in_anonymous_ns"), + usingDecl(InOldCC, unless(InAnonymousNamespace)).bind("using_decl"), this); + // Match anonymous namespace decl in old cc. + Finder->addMatcher(namespaceDecl(isAnonymous(), InOldCC).bind("anonymous_ns"), + this); + // Match static functions/variabale definitions in old cc. Finder->addMatcher( namedDecl(anyOf(functionDecl(isDefinition(), unless(InMovedClass), + unless(InAnonymousNamespace), isStaticStorageClass(), InOldCC), varDecl(isDefinition(), unless(InMovedClass), + unless(InAnonymousNamespace), isStaticStorageClass(), InOldCC))) .bind("static_decls"), this); @@ -398,12 +400,15 @@ // Skip all forwad declarations which appear after moved class declaration. if (RemovedDecls.empty()) MovedDecls.emplace_back(FWD, &Result.Context->getSourceManager()); - } else if (const auto *FD = Result.Nodes.getNodeAs( - "decls_in_anonymous_ns")) { - MovedDecls.emplace_back(FD, &Result.Context->getSourceManager()); + } else if (const auto *ANS = Result.Nodes.getNodeAs( + "anonymous_ns")) { + MovedDecls.emplace_back(ANS, &Result.Context->getSourceManager()); } else if (const auto *ND = Result.Nodes.getNodeAs("static_decls")) { MovedDecls.emplace_back(ND, &Result.Context->getSourceManager()); + } else if (const auto *UD = + Result.Nodes.getNodeAs("using_decl")) { + MovedDecls.emplace_back(UD, &Result.Context->getSourceManager()); } } Index: test/clang-move/Inputs/multiple_class_test.cpp =================================================================== --- test/clang-move/Inputs/multiple_class_test.cpp +++ test/clang-move/Inputs/multiple_class_test.cpp @@ -6,7 +6,13 @@ } } // namespace a +namespace { +using a::Move1; +static int k = 0; +} + namespace b { +using a::Move1; int Move2::f() { return 0; } Index: test/clang-move/move-multiple-classes.cpp =================================================================== --- test/clang-move/move-multiple-classes.cpp +++ test/clang-move/move-multiple-classes.cpp @@ -18,6 +18,10 @@ // CHECK-OLD-TEST-H: } // namespace c // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h" +// CHECK-OLD-TEST-CPP: namespace { +// CHECK-OLD-TEST-CPP: using a::Move1; +// CHECK-OLD-TEST-CPP: static int k = 0; +// CHECK-OLD-TEST-CPP: } // CHECK-OLD-TEST-CPP: namespace c { // CHECK-OLD-TEST-CPP: int NoMove::f() { // CHECK-OLD-TEST-CPP: return 0; @@ -62,7 +66,12 @@ // CHECK-NEW-TEST-CPP: namespace a { // CHECK-NEW-TEST-CPP: int Move1::f() { return 0; } // CHECK-NEW-TEST-CPP: } // namespace a +// CHECK-NEW-TEST-CPP: namespace { +// CHECK-NEW-TEST-CPP: using a::Move1; +// CHECK-NEW-TEST-CPP: static int k = 0; +// CHECK-NEW-TEST-CPP: } // CHECK-NEW-TEST-CPP: namespace b { +// CHECK-NEW-TEST-CPP: using a::Move1; // CHECK-NEW-TEST-CPP: int Move2::f() { return 0; } // CHECK-NEW-TEST-CPP: } // namespace b // CHECK-NEW-TEST-CPP: namespace c {