Index: tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
index dddccd1741bb968b0c99fec10af2bda8a3a5ec5a..6b6b86fc3299fa5af6cb98f577606be962b6d335 100644 |
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
@@ -584,10 +584,31 @@ int main(int argc, const char* argv[]) { |
MatchFinder match_finder; |
std::set<Replacement> replacements; |
- auto in_blink_namespace = |
- decl(hasAncestor(namespaceDecl(anyOf(hasName("blink"), hasName("WTF")), |
- hasParent(translationUnitDecl()))), |
- unless(isExpansionInFileMatching(kGeneratedFileRegex))); |
+ // Blink namespace matchers ======== |
+ auto blink_namespace_decl = |
+ namespaceDecl(anyOf(hasName("blink"), hasName("WTF")), |
+ hasParent(translationUnitDecl())); |
+ |
+ // Given top-level compilation unit: |
+ // namespace WTF { |
+ // void foo() {} |
+ // } |
+ // matches |foo|. |
+ auto decl_under_blink_namespace = decl(hasAncestor(blink_namespace_decl)); |
+ |
+ // Given top-level compilation unit: |
+ // void WTF::function() {} // (1) |
+ // void WTF::Class::method() {} // (2) |
dcheng
2016/08/29 21:12:17
As mentioned offline, this doesn't match something
|
+ // matches |WTF::function| and |WTF::Class::method| decls. |
+ auto decl_has_qualifier_to_blink_namespace = |
+ declaratorDecl(has(nestedNameSpecifier( |
+ anyOf(specifiesNamespace(blink_namespace_decl), // (1) |
+ hasPrefix(specifiesNamespace(blink_namespace_decl)))))); // (2) |
+ |
+ auto in_blink_namespace = decl( |
+ anyOf(decl_under_blink_namespace, decl_has_qualifier_to_blink_namespace, |
+ hasAncestor(decl_has_qualifier_to_blink_namespace)), |
+ unless(isExpansionInFileMatching(kGeneratedFileRegex))); |
// Field, variable, and enum declarations ======== |
// Given |