Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp

Issue 2271203004: Tweak |in_blink_namespace|, to look at ancestors *and also* at qualifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-style-same-type-and-method-name
Patch Set: Handle parameters and variables underneath namespace-less function decl. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/functions-expected.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/functions-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698