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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 return Node.isInstance(); | 81 return Node.isInstance(); |
82 } | 82 } |
83 | 83 |
84 AST_MATCHER_P(clang::FunctionTemplateDecl, | 84 AST_MATCHER_P(clang::FunctionTemplateDecl, |
85 templatedDecl, | 85 templatedDecl, |
86 clang::ast_matchers::internal::Matcher<clang::FunctionDecl>, | 86 clang::ast_matchers::internal::Matcher<clang::FunctionDecl>, |
87 InnerMatcher) { | 87 InnerMatcher) { |
88 return InnerMatcher.matches(*Node.getTemplatedDecl(), Finder, Builder); | 88 return InnerMatcher.matches(*Node.getTemplatedDecl(), Finder, Builder); |
89 } | 89 } |
90 | 90 |
91 AST_MATCHER_P(clang::Decl, | |
92 hasCanonicalDecl, | |
93 clang::ast_matchers::internal::Matcher<clang::Decl>, | |
94 InnerMatcher) { | |
95 return InnerMatcher.matches(*Node.getCanonicalDecl(), Finder, Builder); | |
96 } | |
97 | |
91 // Matches a CXXMethodDecl of a method declared via MOCK_METHODx macro if such | 98 // Matches a CXXMethodDecl of a method declared via MOCK_METHODx macro if such |
92 // method mocks a method matched by the InnerMatcher. For example if "foo" | 99 // method mocks a method matched by the InnerMatcher. For example if "foo" |
93 // matcher matches "interfaceMethod", then mocksMethod(foo()) will match | 100 // matcher matches "interfaceMethod", then mocksMethod(foo()) will match |
94 // "gmock_interfaceMethod" declared by MOCK_METHOD_x(interfaceMethod). | 101 // "gmock_interfaceMethod" declared by MOCK_METHOD_x(interfaceMethod). |
95 AST_MATCHER_P(clang::CXXMethodDecl, | 102 AST_MATCHER_P(clang::CXXMethodDecl, |
96 mocksMethod, | 103 mocksMethod, |
97 clang::ast_matchers::internal::Matcher<clang::CXXMethodDecl>, | 104 clang::ast_matchers::internal::Matcher<clang::CXXMethodDecl>, |
98 InnerMatcher) { | 105 InnerMatcher) { |
99 if (!Node.getDeclName().isIdentifier()) | 106 if (!Node.getDeclName().isIdentifier()) |
100 return false; | 107 return false; |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1432 // void WTF::function() {} | 1439 // void WTF::function() {} |
1433 // void WTF::Class::method() {} | 1440 // void WTF::Class::method() {} |
1434 // matches |WTF::function| and |WTF::Class::method| decls. | 1441 // matches |WTF::function| and |WTF::Class::method| decls. |
1435 auto decl_has_qualifier_to_blink_namespace = | 1442 auto decl_has_qualifier_to_blink_namespace = |
1436 declaratorDecl(has(nestedNameSpecifier( | 1443 declaratorDecl(has(nestedNameSpecifier( |
1437 hasTopLevelPrefix(specifiesNamespace(blink_namespace_decl))))); | 1444 hasTopLevelPrefix(specifiesNamespace(blink_namespace_decl))))); |
1438 | 1445 |
1439 auto in_blink_namespace = decl( | 1446 auto in_blink_namespace = decl( |
1440 anyOf(decl_under_blink_namespace, decl_has_qualifier_to_blink_namespace, | 1447 anyOf(decl_under_blink_namespace, decl_has_qualifier_to_blink_namespace, |
1441 hasAncestor(decl_has_qualifier_to_blink_namespace)), | 1448 hasAncestor(decl_has_qualifier_to_blink_namespace)), |
1442 unless(isExpansionInFileMatching(kGeneratedFileRegex))); | 1449 unless(hasCanonicalDecl(isExpansionInFileMatching(kGeneratedFileRegex)))); |
Łukasz Anforowicz
2017/01/21 01:04:00
These are the only real changes from patchset #1.
| |
1443 | 1450 |
1444 // Field, variable, and enum declarations ======== | 1451 // Field, variable, and enum declarations ======== |
1445 // Given | 1452 // Given |
1446 // int x; | 1453 // int x; |
1447 // struct S { | 1454 // struct S { |
1448 // int y; | 1455 // int y; |
1449 // enum { VALUE }; | 1456 // enum { VALUE }; |
1450 // }; | 1457 // }; |
1451 // matches |x|, |y|, and |VALUE|. | 1458 // matches |x|, |y|, and |VALUE|. |
1452 auto field_decl_matcher = id("decl", fieldDecl(in_blink_namespace)); | 1459 auto field_decl_matcher = id("decl", fieldDecl(in_blink_namespace)); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1805 for (const auto& r : replacements) { | 1812 for (const auto& r : replacements) { |
1806 std::string replacement_text = r.getReplacementText().str(); | 1813 std::string replacement_text = r.getReplacementText().str(); |
1807 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); | 1814 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); |
1808 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() | 1815 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() |
1809 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; | 1816 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; |
1810 } | 1817 } |
1811 llvm::outs() << "==== END EDITS ====\n"; | 1818 llvm::outs() << "==== END EDITS ====\n"; |
1812 | 1819 |
1813 return 0; | 1820 return 0; |
1814 } | 1821 } |
OLD | NEW |