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

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

Issue 2307643002: Account for the fact that some type traits have static methods. (Closed)
Patch Set: Taking car of type traits with enum value. Created 4 years, 3 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/fields-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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const char kGeneratedFileRegex[] = "^gen/|/gen/"; 52 const char kGeneratedFileRegex[] = "^gen/|/gen/";
53 53
54 const clang::ast_matchers::internal:: 54 const clang::ast_matchers::internal::
55 VariadicDynCastAllOfMatcher<clang::Expr, clang::UnresolvedMemberExpr> 55 VariadicDynCastAllOfMatcher<clang::Expr, clang::UnresolvedMemberExpr>
56 unresolvedMemberExpr; 56 unresolvedMemberExpr;
57 57
58 AST_MATCHER(clang::FunctionDecl, isOverloadedOperator) { 58 AST_MATCHER(clang::FunctionDecl, isOverloadedOperator) {
59 return Node.isOverloadedOperator(); 59 return Node.isOverloadedOperator();
60 } 60 }
61 61
62 AST_MATCHER(clang::CXXMethodDecl, isInstanceMethod) {
63 return Node.isInstance();
64 }
65
62 AST_MATCHER_P(clang::FunctionTemplateDecl, 66 AST_MATCHER_P(clang::FunctionTemplateDecl,
63 templatedDecl, 67 templatedDecl,
64 clang::ast_matchers::internal::Matcher<clang::FunctionDecl>, 68 clang::ast_matchers::internal::Matcher<clang::FunctionDecl>,
65 InnerMatcher) { 69 InnerMatcher) {
66 return InnerMatcher.matches(*Node.getTemplatedDecl(), Finder, Builder); 70 return InnerMatcher.matches(*Node.getTemplatedDecl(), Finder, Builder);
67 } 71 }
68 72
69 // If |InnerMatcher| matches |top|, then the returned matcher will match: 73 // If |InnerMatcher| matches |top|, then the returned matcher will match:
70 // - |top::function| 74 // - |top::function|
71 // - |top::Class::method| 75 // - |top::Class::method|
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 // Given 639 // Given
636 // int x; 640 // int x;
637 // struct S { 641 // struct S {
638 // int y; 642 // int y;
639 // enum { VALUE }; 643 // enum { VALUE };
640 // }; 644 // };
641 // matches |x|, |y|, and |VALUE|. 645 // matches |x|, |y|, and |VALUE|.
642 auto field_decl_matcher = id("decl", fieldDecl(in_blink_namespace)); 646 auto field_decl_matcher = id("decl", fieldDecl(in_blink_namespace));
643 auto is_type_trait_value = 647 auto is_type_trait_value =
644 varDecl(hasName("value"), hasStaticStorageDuration(), isPublic(), 648 varDecl(hasName("value"), hasStaticStorageDuration(), isPublic(),
645 hasType(isConstQualified()), hasType(booleanType()), 649 hasType(isConstQualified()), hasType(type(anyOf(
646 unless(hasAncestor(recordDecl(has(functionDecl()))))); 650 booleanType(), enumType()))),
651 unless(hasAncestor(recordDecl(
652 has(cxxMethodDecl(isUserProvided(), isInstanceMethod()))))));
647 auto var_decl_matcher = 653 auto var_decl_matcher =
648 id("decl", varDecl(in_blink_namespace, unless(is_type_trait_value))); 654 id("decl", varDecl(in_blink_namespace, unless(is_type_trait_value)));
649 auto enum_member_decl_matcher = 655 auto enum_member_decl_matcher =
650 id("decl", enumConstantDecl(in_blink_namespace)); 656 id("decl", enumConstantDecl(in_blink_namespace));
651 657
652 FieldDeclRewriter field_decl_rewriter(&replacements); 658 FieldDeclRewriter field_decl_rewriter(&replacements);
653 match_finder.addMatcher(field_decl_matcher, &field_decl_rewriter); 659 match_finder.addMatcher(field_decl_matcher, &field_decl_rewriter);
654 660
655 VarDeclRewriter var_decl_rewriter(&replacements); 661 VarDeclRewriter var_decl_rewriter(&replacements);
656 match_finder.addMatcher(var_decl_matcher, &var_decl_rewriter); 662 match_finder.addMatcher(var_decl_matcher, &var_decl_rewriter);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 for (const auto& r : replacements) { 932 for (const auto& r : replacements) {
927 std::string replacement_text = r.getReplacementText().str(); 933 std::string replacement_text = r.getReplacementText().str();
928 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 934 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
929 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 935 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
930 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 936 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
931 } 937 }
932 llvm::outs() << "==== END EDITS ====\n"; 938 llvm::outs() << "==== END EDITS ====\n";
933 939
934 return 0; 940 return 0;
935 } 941 }
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/fields-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698