diff options
author | dcheng <dcheng@chromium.org> | 2016-01-21 14:08:51 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-21 22:10:26 +0000 |
commit | 387a1d91ab2629f483da15d3aaffa103fd12811e (patch) | |
tree | 3800f47257df09e94efe4d4594977e397ac597ca /tools/clang | |
parent | f581d48dd805ff2d30a3c08a9cc0aef5f61c8747 (diff) | |
download | chromium_src-387a1d91ab2629f483da15d3aaffa103fd12811e.zip chromium_src-387a1d91ab2629f483da15d3aaffa103fd12811e.tar.gz chromium_src-387a1d91ab2629f483da15d3aaffa103fd12811e.tar.bz2 |
rewrite_to_chrome_style: exclude conversion functions from being renamed
BUG=578344
Review URL: https://codereview.chromium.org/1617253002
Cr-Commit-Position: refs/heads/master@{#370802}
Diffstat (limited to 'tools/clang')
3 files changed, 21 insertions, 5 deletions
diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp index fcbd921..78df7a3 100644 --- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp +++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp @@ -432,9 +432,11 @@ int main(int argc, const char* argv[]) { // Overloaded operators have special names // and should never be renamed. isOverloadedOperator(), - // Similarly, constructors and destructors - // should not be considered for renaming. - cxxConstructorDecl(), cxxDestructorDecl())), + // Similarly, constructors, destructors, and + // conversion functions should not be + // considered for renaming. + cxxConstructorDecl(), cxxDestructorDecl(), + cxxConversionDecl())), in_blink_namespace)); // Note that the matcher for overridden methods doesn't need to filter for // special member functions: see implementation of FunctionDeclRewriter for diff --git a/tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc b/tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc index 719acfb..0b35d83 100644 --- a/tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc +++ b/tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc @@ -16,7 +16,12 @@ class Task { // Note: this is purposely copyable and assignable, to make sure the Clang // tool doesn't try to emit replacements for things that aren't explicitly // written. - // TODO(dcheng): Add an explicit test for something like operator+. + + // Overloaded operators should not be rewritten. + Task& operator++() { return *this; } + + // Conversion functions should not be rewritten. + explicit operator int() const { return 42; } }; // Test that the actual method definition is also updated. diff --git a/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc b/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc index cc76490..8dc9b78 100644 --- a/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc +++ b/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc @@ -16,7 +16,16 @@ class Task { // Note: this is purposely copyable and assignable, to make sure the Clang // tool doesn't try to emit replacements for things that aren't explicitly // written. - // TODO(dcheng): Add an explicit test for something like operator+. + + // Overloaded operators should not be rewritten. + Task& operator++() { + return *this; + } + + // Conversion functions should not be rewritten. + explicit operator int() const { + return 42; + } }; // Test that the actual method definition is also updated. |