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

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

Issue 1778963003: rewrite_to_chrome_style: Exclude methods before checking IsBlinkOrWTF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | no next file » | 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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 match_finder.addMatcher(function_ref_matcher, &function_ref_rewriter); 633 match_finder.addMatcher(function_ref_matcher, &function_ref_rewriter);
634 634
635 // Method declarations ======== 635 // Method declarations ========
636 // Given 636 // Given
637 // struct S { 637 // struct S {
638 // void g(); 638 // void g();
639 // }; 639 // };
640 // matches |g|. 640 // matches |g|.
641 auto method_decl_matcher = 641 auto method_decl_matcher =
642 id("decl", 642 id("decl",
643 cxxMethodDecl(isBlinkOrWTFMethod(), 643 cxxMethodDecl(unless(anyOf(is_generated,
644 unless(anyOf(is_generated,
645 // Overloaded operators have special names 644 // Overloaded operators have special names
646 // and should never be renamed. 645 // and should never be renamed.
647 isOverloadedOperator(), 646 isOverloadedOperator(),
648 // Similarly, constructors, destructors, and 647 // Similarly, constructors, destructors, and
649 // conversion functions should not be 648 // conversion functions should not be
650 // considered for renaming. 649 // considered for renaming.
651 cxxConstructorDecl(), cxxDestructorDecl(), 650 cxxConstructorDecl(), cxxDestructorDecl(),
652 cxxConversionDecl())))); 651 cxxConversionDecl())),
652 // Check this last after excluding things, to avoid
653 // asserts about overriding non-blink and blink for the
654 // same method.
655 isBlinkOrWTFMethod()));
653 MethodDeclRewriter method_decl_rewriter(&replacements); 656 MethodDeclRewriter method_decl_rewriter(&replacements);
654 match_finder.addMatcher(method_decl_matcher, &method_decl_rewriter); 657 match_finder.addMatcher(method_decl_matcher, &method_decl_rewriter);
655 658
656 // Method references in a non-member context ======== 659 // Method references in a non-member context ========
657 // Given 660 // Given
658 // S s; 661 // S s;
659 // s.g(); 662 // s.g();
660 // void (S::*p)() = &S::g; 663 // void (S::*p)() = &S::g;
661 // matches |&S::g| but not |s.g()|. 664 // matches |&S::g| but not |s.g()|.
662 auto method_ref_matcher = id("expr", declRefExpr(to(method_decl_matcher))); 665 auto method_ref_matcher = id("expr", declRefExpr(to(method_decl_matcher)));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 for (const auto& r : replacements) { 758 for (const auto& r : replacements) {
756 std::string replacement_text = r.getReplacementText().str(); 759 std::string replacement_text = r.getReplacementText().str();
757 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 760 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
758 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 761 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
759 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 762 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
760 } 763 }
761 llvm::outs() << "==== END EDITS ====\n"; 764 llvm::outs() << "==== END EDITS ====\n";
762 765
763 return 0; 766 return 0;
764 } 767 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698