diff options
author | danakj <danakj@chromium.org> | 2016-01-21 17:07:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-22 01:10:57 +0000 |
commit | bef818c73338f376091cd7e3f013c2f48c0a4e51 (patch) | |
tree | 4766feea3855ab3962383a5cef76016712fb2946 /tools/clang | |
parent | 3708efb85b5467137d76bdfb17c9fc1eab420318 (diff) | |
download | chromium_src-bef818c73338f376091cd7e3f013c2f48c0a4e51.zip chromium_src-bef818c73338f376091cd7e3f013c2f48c0a4e51.tar.gz chromium_src-bef818c73338f376091cd7e3f013c2f48c0a4e51.tar.bz2 |
rewrite_to_chrome_style: Handle non-method overloaded operators
By ignoring them, we should not try rename symbols.
R=dcheng
BUG=578344
Review URL: https://codereview.chromium.org/1612223002
Cr-Commit-Position: refs/heads/master@{#370860}
Diffstat (limited to 'tools/clang')
3 files changed, 60 insertions, 2 deletions
diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp index 78df7a3..98b4c94 100644 --- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp +++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp @@ -399,8 +399,16 @@ int main(int argc, const char* argv[]) { // void g(); // }; // matches |f| but not |g|. - auto function_decl_matcher = - id("decl", functionDecl(unless(cxxMethodDecl()), in_blink_namespace)); + auto function_decl_matcher = id( + "decl", + functionDecl( + unless(anyOf( + // Methods are covered by the method matchers. + cxxMethodDecl(), + // Out-of-line overloaded operators have special names and should + // never be renamed. + isOverloadedOperator())), + in_blink_namespace)); FunctionDeclRewriter function_decl_rewriter(&replacements); match_finder.addMatcher(function_decl_matcher, &function_decl_rewriter); diff --git a/tools/clang/rewrite_to_chrome_style/tests/operators-expected.cc b/tools/clang/rewrite_to_chrome_style/tests/operators-expected.cc new file mode 100644 index 0000000..7f470c6 --- /dev/null +++ b/tools/clang/rewrite_to_chrome_style/tests/operators-expected.cc @@ -0,0 +1,25 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +namespace blink { + +struct Op { + bool operator==(const Op&) { return true; } +}; + +struct Op2 {}; + +inline bool operator==(const Op2&, const Op2) { + return true; +} + +} // namespace + +void G() { + blink::Op a, b; + bool c = a == b; + + blink::Op2 a2, b2; + bool c2 = a2 == b2; +} diff --git a/tools/clang/rewrite_to_chrome_style/tests/operators-original.cc b/tools/clang/rewrite_to_chrome_style/tests/operators-original.cc new file mode 100644 index 0000000..7f470c6 --- /dev/null +++ b/tools/clang/rewrite_to_chrome_style/tests/operators-original.cc @@ -0,0 +1,25 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +namespace blink { + +struct Op { + bool operator==(const Op&) { return true; } +}; + +struct Op2 {}; + +inline bool operator==(const Op2&, const Op2) { + return true; +} + +} // namespace + +void G() { + blink::Op a, b; + bool c = a == b; + + blink::Op2 a2, b2; + bool c2 = a2 == b2; +} |