diff options
author | dcheng <dcheng@chromium.org> | 2016-02-05 14:50:46 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-05 22:51:41 +0000 |
commit | 6a5cf3068db92419ca28a4fab3c638eae68e9205 (patch) | |
tree | f3fc1c5e30957562294cc502115aa2bff4fadc53 /tools | |
parent | 82c760211d465e7ec72290c477ce2ded3a6db72e (diff) | |
download | chromium_src-6a5cf3068db92419ca28a4fab3c638eae68e9205.zip chromium_src-6a5cf3068db92419ca28a4fab3c638eae68e9205.tar.gz chromium_src-6a5cf3068db92419ca28a4fab3c638eae68e9205.tar.bz2 |
Don't rename enumerators that are already SHOUTY_CASE.
BUG=580740
Review URL: https://codereview.chromium.org/1676703003
Cr-Commit-Position: refs/heads/master@{#373931}
Diffstat (limited to 'tools')
3 files changed, 20 insertions, 0 deletions
diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp index 6df3096..0cc6ce0 100644 --- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp +++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp @@ -198,6 +198,16 @@ bool GetNameForDecl(const clang::EnumConstantDecl& decl, std::string& name) { StringRef original_name = decl.getName(); + bool already_shouty = true; + for (char c : original_name) { + if (!clang::isUppercase(c) && !clang::isDigit(c) && c != '_') { + already_shouty = false; + break; + } + } + if (already_shouty) + return false; + name = CamelCaseToUnderscoreCase(original_name, true); for (auto& c : name) c = clang::toUppercase(c); diff --git a/tools/clang/rewrite_to_chrome_style/tests/enums-expected.cc b/tools/clang/rewrite_to_chrome_style/tests/enums-expected.cc index 8d8f2bd..1ecdea0 100644 --- a/tools/clang/rewrite_to_chrome_style/tests/enums-expected.cc +++ b/tools/clang/rewrite_to_chrome_style/tests/enums-expected.cc @@ -31,6 +31,11 @@ class T { }; }; +// Already SHOUT_CAPS, so the naming shouldn't change. +enum AlreadyShouty { + ENABLE_DIRECTZ3000_SUPPORT_FOR_HL3E1, +}; + } // namespace blink enum EnumOutsideNamespace { diff --git a/tools/clang/rewrite_to_chrome_style/tests/enums-original.cc b/tools/clang/rewrite_to_chrome_style/tests/enums-original.cc index b248290..000a41e 100644 --- a/tools/clang/rewrite_to_chrome_style/tests/enums-original.cc +++ b/tools/clang/rewrite_to_chrome_style/tests/enums-original.cc @@ -31,6 +31,11 @@ class T { }; }; +// Already SHOUT_CAPS, so the naming shouldn't change. +enum AlreadyShouty { + ENABLE_DIRECTZ3000_SUPPORT_FOR_HL3E1, +}; + } // namespace blink enum EnumOutsideNamespace { |