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

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

Issue 1612223002: rewrite_to_chrome_style: Handle non-method overloaded operators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rewrite-operators: commentfix Created 4 years, 11 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/operators-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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 DeclRefRewriter decl_ref_rewriter(&replacements); 392 DeclRefRewriter decl_ref_rewriter(&replacements);
393 match_finder.addMatcher(decl_ref_matcher, &decl_ref_rewriter); 393 match_finder.addMatcher(decl_ref_matcher, &decl_ref_rewriter);
394 394
395 // Non-method function declarations ======== 395 // Non-method function declarations ========
396 // Given 396 // Given
397 // void f(); 397 // void f();
398 // struct S { 398 // struct S {
399 // void g(); 399 // void g();
400 // }; 400 // };
401 // matches |f| but not |g|. 401 // matches |f| but not |g|.
402 auto function_decl_matcher = 402 auto function_decl_matcher = id(
403 id("decl", functionDecl(unless(cxxMethodDecl()), in_blink_namespace)); 403 "decl",
404 functionDecl(
405 unless(anyOf(
406 // Methods are covered by the method matchers.
407 cxxMethodDecl(),
408 // Out-of-line overloaded operators have special names and should
409 // never be renamed.
410 isOverloadedOperator())),
411 in_blink_namespace));
404 FunctionDeclRewriter function_decl_rewriter(&replacements); 412 FunctionDeclRewriter function_decl_rewriter(&replacements);
405 match_finder.addMatcher(function_decl_matcher, &function_decl_rewriter); 413 match_finder.addMatcher(function_decl_matcher, &function_decl_rewriter);
406 414
407 // Non-method function references ======== 415 // Non-method function references ========
408 // Given 416 // Given
409 // f(); 417 // f();
410 // void (*p)() = &f; 418 // void (*p)() = &f;
411 // matches |f()| and |&f|. 419 // matches |f()| and |&f|.
412 auto function_ref_matcher = 420 auto function_ref_matcher =
413 id("expr", declRefExpr(to(function_decl_matcher))); 421 id("expr", declRefExpr(to(function_decl_matcher)));
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 for (const auto& r : replacements) { 528 for (const auto& r : replacements) {
521 std::string replacement_text = r.getReplacementText().str(); 529 std::string replacement_text = r.getReplacementText().str();
522 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 530 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
523 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 531 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
524 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 532 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
525 } 533 }
526 llvm::outs() << "==== END EDITS ====\n"; 534 llvm::outs() << "==== END EDITS ====\n";
527 535
528 return 0; 536 return 0;
529 } 537 }
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/operators-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698