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

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

Issue 1647763002: rewrite_to_chrome_style: Don't rename begin()/end()/rbegin()/rend(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rewrite-begin-end: . Created 4 years, 10 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/functions-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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return Node.isOverloadedOperator(); 53 return Node.isOverloadedOperator();
54 } 54 }
55 55
56 constexpr char kBlinkFieldPrefix[] = "m_"; 56 constexpr char kBlinkFieldPrefix[] = "m_";
57 constexpr char kBlinkStaticMemberPrefix[] = "s_"; 57 constexpr char kBlinkStaticMemberPrefix[] = "s_";
58 58
59 bool GetNameForDecl(const clang::FunctionDecl& decl, 59 bool GetNameForDecl(const clang::FunctionDecl& decl,
60 const clang::ASTContext& context, 60 const clang::ASTContext& context,
61 std::string& name) { 61 std::string& name) {
62 name = decl.getNameAsString(); 62 name = decl.getNameAsString();
63
64 if (const auto* method = clang::dyn_cast<const clang::CXXMethodDecl>(&decl)) {
dcheng 2016/01/28 20:20:33 Nit: dyn_cast<clang::CXXMethodDecl> should work.
danakj 2016/01/28 21:26:38 Nope..
65 if (!method->isStatic()) {
66 // Some methods shouldn't be renamed because reasons.
67 static const char* kBlacklist[] = {"begin", "end", "rbegin", "rend",
68 "trace"};
69 for (const auto& b : kBlacklist) {
70 if (name == b)
71 return false;
72 }
73 }
74 }
75
63 name[0] = clang::toUppercase(name[0]); 76 name[0] = clang::toUppercase(name[0]);
64 return true; 77 return true;
65 } 78 }
66 79
67 // Helper to convert from a camelCaseName to camel_case_name. It uses some 80 // Helper to convert from a camelCaseName to camel_case_name. It uses some
68 // heuristics to try to handle acronyms in camel case names correctly. 81 // heuristics to try to handle acronyms in camel case names correctly.
69 std::string CamelCaseToUnderscoreCase(StringRef input) { 82 std::string CamelCaseToUnderscoreCase(StringRef input) {
70 std::string output; 83 std::string output;
71 bool needs_underscore = false; 84 bool needs_underscore = false;
72 bool was_lowercase = false; 85 bool was_lowercase = false;
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 for (const auto& r : replacements) { 568 for (const auto& r : replacements) {
556 std::string replacement_text = r.getReplacementText().str(); 569 std::string replacement_text = r.getReplacementText().str();
557 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 570 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
558 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 571 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
559 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 572 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
560 } 573 }
561 llvm::outs() << "==== END EDITS ====\n"; 574 llvm::outs() << "==== END EDITS ====\n";
562 575
563 return 0; 576 return 0;
564 } 577 }
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/functions-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698