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

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

Issue 2657773003: Blacklisting renaming of |size()| and |length()| methods. (Closed)
Patch Set: Let's also blacklist |length| per https://crbug.com/672902#c9 Created 3 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 | 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 bool IsBlacklistedInstanceMethodName(llvm::StringRef name) { 432 bool IsBlacklistedInstanceMethodName(llvm::StringRef name) {
433 static const char* kBlacklistedNames[] = { 433 static const char* kBlacklistedNames[] = {
434 // We should avoid renaming the method names listed below, because 434 // We should avoid renaming the method names listed below, because
435 // 1. They are used in templated code (e.g. in <algorithms>) 435 // 1. They are used in templated code (e.g. in <algorithms>)
436 // 2. They (begin+end) are used in range-based for syntax sugar 436 // 2. They (begin+end) are used in range-based for syntax sugar
437 // - for (auto x : foo) { ... } // <- foo.begin() will be called. 437 // - for (auto x : foo) { ... } // <- foo.begin() will be called.
438 "begin", "end", "rbegin", "rend", "lock", "unlock", "try_lock", 438 "begin", "end", "rbegin", "rend", "lock", "unlock", "try_lock",
439 439
440 // https://crbug.com/672902: Should not rewrite names that mimick methods 440 // https://crbug.com/672902: Should not rewrite names that mimick methods
441 // from std library. 441 // from std library.
442 "back", "empty", "erase", "front", "insert", 442 "back", "empty", "erase", "front", "insert", "length", "size",
443 }; 443 };
444 for (const auto& b : kBlacklistedNames) { 444 for (const auto& b : kBlacklistedNames) {
445 if (name == b) 445 if (name == b)
446 return true; 446 return true;
447 } 447 }
448 return false; 448 return false;
449 } 449 }
450 450
451 bool IsBlacklistedMethodName(llvm::StringRef name) { 451 bool IsBlacklistedMethodName(llvm::StringRef name) {
452 return IsBlacklistedFunctionName(name) || 452 return IsBlacklistedFunctionName(name) ||
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 "hash", 655 "hash",
656 "heapObjectHeader", 656 "heapObjectHeader",
657 "iconURL", 657 "iconURL",
658 "image", 658 "image",
659 "inputMethodController", 659 "inputMethodController",
660 "inputType", 660 "inputType",
661 "layout", 661 "layout",
662 "layoutBlock", 662 "layoutBlock",
663 "layoutObject", 663 "layoutObject",
664 "layoutSize", 664 "layoutSize",
665 "length",
666 "lineCap", 665 "lineCap",
667 "lineEndings", 666 "lineEndings",
668 "lineJoin", 667 "lineJoin",
669 "listItems", 668 "listItems",
670 "matchedProperties", 669 "matchedProperties",
671 "midpointState", 670 "midpointState",
672 "modifiers", 671 "modifiers",
673 "mouseEvent", 672 "mouseEvent",
674 "name", 673 "name",
675 "navigationType", 674 "navigationType",
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 for (const auto& r : replacements) { 1849 for (const auto& r : replacements) {
1851 std::string replacement_text = r.getReplacementText().str(); 1850 std::string replacement_text = r.getReplacementText().str();
1852 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 1851 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
1853 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 1852 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
1854 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 1853 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
1855 } 1854 }
1856 llvm::outs() << "==== END EDITS ====\n"; 1855 llvm::outs() << "==== END EDITS ====\n";
1857 1856
1858 return 0; 1857 return 0;
1859 } 1858 }
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