| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |