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

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

Issue 2868923002: Blink rename follow-up: Use Chromium style in network_instrumentation namespace. (Closed)
Patch Set: Created 3 years, 7 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
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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 bool IsBlacklistedInstanceMethodName(llvm::StringRef name) { 421 bool IsBlacklistedInstanceMethodName(llvm::StringRef name) {
422 static const char* kBlacklistedNames[] = { 422 static const char* kBlacklistedNames[] = {
423 // We should avoid renaming the method names listed below, because 423 // We should avoid renaming the method names listed below, because
424 // 1. They are used in templated code (e.g. in <algorithms>) 424 // 1. They are used in templated code (e.g. in <algorithms>)
425 // 2. They (begin+end) are used in range-based for syntax sugar 425 // 2. They (begin+end) are used in range-based for syntax sugar
426 // - for (auto x : foo) { ... } // <- foo.begin() will be called. 426 // - for (auto x : foo) { ... } // <- foo.begin() will be called.
427 "begin", "end", "rbegin", "rend", "lock", "unlock", "try_lock", 427 "begin", "end", "rbegin", "rend", "lock", "unlock", "try_lock",
428 428
429 // https://crbug.com/672902: Should not rewrite names that mimick methods 429 // https://crbug.com/672902: Should not rewrite names that mimick methods
430 // from std library. 430 // from std library.
431 "at", "back", "empty", "erase", "front", "insert", "length", "size", 431 "at", "back",
432 "clear"
433 "empty",
434 "erase", "find", "front", "insert", "length", "size", "swap",
Łukasz Anforowicz 2017/05/08 17:09:45 Above formatting was produced by clang-format. I'
432 }; 435 };
433 for (const auto& b : kBlacklistedNames) { 436 for (const auto& b : kBlacklistedNames) {
434 if (name == b) 437 if (name == b)
435 return true; 438 return true;
436 } 439 }
437 return false; 440 return false;
438 } 441 }
439 442
440 bool IsBlacklistedMethodName(llvm::StringRef name) { 443 bool IsBlacklistedMethodName(llvm::StringRef name) {
441 return IsBlacklistedFunctionName(name) || 444 return IsBlacklistedFunctionName(name) ||
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 CommonOptionsParser options(argc, argv, category); 1528 CommonOptionsParser options(argc, argv, category);
1526 MethodBlocklist method_blocklist(blocklisted_methods_file); 1529 MethodBlocklist method_blocklist(blocklisted_methods_file);
1527 clang::tooling::ClangTool tool(options.getCompilations(), 1530 clang::tooling::ClangTool tool(options.getCompilations(),
1528 options.getSourcePathList()); 1531 options.getSourcePathList());
1529 1532
1530 MatchFinder match_finder; 1533 MatchFinder match_finder;
1531 std::set<Replacement> replacements; 1534 std::set<Replacement> replacements;
1532 1535
1533 // Blink namespace matchers ======== 1536 // Blink namespace matchers ========
1534 auto blink_namespace_decl = 1537 auto blink_namespace_decl =
1535 namespaceDecl(anyOf(hasName("blink"), hasName("WTF")), 1538 namespaceDecl(anyOf(hasName("blink"), hasName("WTF"),
1539 hasName("network_instrumentation")),
1536 hasParent(translationUnitDecl())); 1540 hasParent(translationUnitDecl()));
1537 auto protocol_namespace_decl = 1541 auto protocol_namespace_decl =
1538 namespaceDecl(hasName("protocol"), 1542 namespaceDecl(hasName("protocol"),
1539 hasParent(namespaceDecl(hasName("blink"), 1543 hasParent(namespaceDecl(hasName("blink"),
1540 hasParent(translationUnitDecl())))); 1544 hasParent(translationUnitDecl()))));
1541 1545
1542 // Given top-level compilation unit: 1546 // Given top-level compilation unit:
1543 // namespace WTF { 1547 // namespace WTF {
1544 // void foo() {} 1548 // void foo() {}
1545 // } 1549 // }
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 for (const auto& r : replacements) { 1956 for (const auto& r : replacements) {
1953 std::string replacement_text = r.getReplacementText().str(); 1957 std::string replacement_text = r.getReplacementText().str();
1954 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 1958 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
1955 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 1959 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
1956 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 1960 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
1957 } 1961 }
1958 llvm::outs() << "==== END EDITS ====\n"; 1962 llvm::outs() << "==== END EDITS ====\n";
1959 1963
1960 return 0; 1964 return 0;
1961 } 1965 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698