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

Side by Side Diff: tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp

Issue 2625903006: Blacklist renaming inside blink::protocol namespace. (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/namespaces-expected.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Changes Blink-style names to Chrome-style names. Currently transforms: 5 // Changes Blink-style names to Chrome-style names. Currently transforms:
6 // fields: 6 // fields:
7 // int m_operationCount => int operation_count_ 7 // int m_operationCount => int operation_count_
8 // variables (including parameters): 8 // variables (including parameters):
9 // int mySuperVariable => int my_super_variable 9 // int mySuperVariable => int my_super_variable
10 // constants: 10 // constants:
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 clang::tooling::ClangTool tool(options.getCompilations(), 1035 clang::tooling::ClangTool tool(options.getCompilations(),
1036 options.getSourcePathList()); 1036 options.getSourcePathList());
1037 1037
1038 MatchFinder match_finder; 1038 MatchFinder match_finder;
1039 std::set<Replacement> replacements; 1039 std::set<Replacement> replacements;
1040 1040
1041 // Blink namespace matchers ======== 1041 // Blink namespace matchers ========
1042 auto blink_namespace_decl = 1042 auto blink_namespace_decl =
1043 namespaceDecl(anyOf(hasName("blink"), hasName("WTF")), 1043 namespaceDecl(anyOf(hasName("blink"), hasName("WTF")),
1044 hasParent(translationUnitDecl())); 1044 hasParent(translationUnitDecl()));
1045 auto protocol_namespace_decl =
1046 namespaceDecl(hasName("protocol"),
1047 hasParent(namespaceDecl(hasName("blink"),
1048 hasParent(translationUnitDecl()))));
1045 1049
1046 // Given top-level compilation unit: 1050 // Given top-level compilation unit:
1047 // namespace WTF { 1051 // namespace WTF {
1048 // void foo() {} 1052 // void foo() {}
1049 // } 1053 // }
1050 // matches |foo|. 1054 // matches |foo|.
1051 auto decl_under_blink_namespace = decl(hasAncestor(blink_namespace_decl)); 1055 auto decl_under_blink_namespace =
1056 decl(hasAncestor(blink_namespace_decl),
1057 unless(hasAncestor(protocol_namespace_decl)));
1052 1058
1053 // Given top-level compilation unit: 1059 // Given top-level compilation unit:
1054 // void WTF::function() {} 1060 // void WTF::function() {}
1055 // void WTF::Class::method() {} 1061 // void WTF::Class::method() {}
1056 // matches |WTF::function| and |WTF::Class::method| decls. 1062 // matches |WTF::function| and |WTF::Class::method| decls.
1057 auto decl_has_qualifier_to_blink_namespace = 1063 auto decl_has_qualifier_to_blink_namespace =
1058 declaratorDecl(has(nestedNameSpecifier( 1064 declaratorDecl(has(nestedNameSpecifier(
1059 hasTopLevelPrefix(specifiesNamespace(blink_namespace_decl))))); 1065 hasTopLevelPrefix(specifiesNamespace(blink_namespace_decl)))));
1060 1066
1061 auto in_blink_namespace = decl( 1067 auto in_blink_namespace = decl(
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 for (const auto& r : replacements) { 1415 for (const auto& r : replacements) {
1410 std::string replacement_text = r.getReplacementText().str(); 1416 std::string replacement_text = r.getReplacementText().str();
1411 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 1417 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
1412 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 1418 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
1413 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 1419 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
1414 } 1420 }
1415 llvm::outs() << "==== END EDITS ====\n"; 1421 llvm::outs() << "==== END EDITS ====\n";
1416 1422
1417 return 0; 1423 return 0;
1418 } 1424 }
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/namespaces-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698