summaryrefslogtreecommitdiffstats
path: root/tools/clang
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2016-01-27 17:15:58 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-28 01:17:29 +0000
commit0915b0fadc62314b8eeb497bf37605158d31b5e9 (patch)
tree667f47f2c0321ae4ed7ca2054827b3f7f71e4385 /tools/clang
parentb331323047cf6c2c3fb288f45573f2897a5168da (diff)
downloadchromium_src-0915b0fadc62314b8eeb497bf37605158d31b5e9.zip
chromium_src-0915b0fadc62314b8eeb497bf37605158d31b5e9.tar.gz
chromium_src-0915b0fadc62314b8eeb497bf37605158d31b5e9.tar.bz2
rewrite_to_chrome_style: Don't put a trailing _ on static consts.
These are named in kFooBar style, which doesn't need an underscore. The name should not change if we moved it to an enum, and this is the overwhelming (always used) style for nested constants in chromium. R=dcheng BUG=580746 Review URL: https://codereview.chromium.org/1644803002 Cr-Commit-Position: refs/heads/master@{#371951}
Diffstat (limited to 'tools/clang')
-rw-r--r--tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp7
-rw-r--r--tools/clang/rewrite_to_chrome_style/tests/constants-expected.cc6
2 files changed, 8 insertions, 5 deletions
diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
index 08ce7b7..f9aed1e 100644
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
@@ -159,7 +159,8 @@ bool GetNameForDecl(const clang::VarDecl& decl,
else if (original_name.startswith(kBlinkFieldPrefix))
original_name = original_name.substr(strlen(kBlinkFieldPrefix));
- if (IsProbablyConst(decl, context)) {
+ bool is_const = IsProbablyConst(decl, context);
+ if (is_const) {
// Don't try to rename constants that already conform to Chrome style.
if (original_name.size() >= 2 && original_name[0] == 'k' &&
clang::isUppercase(original_name[1]))
@@ -171,7 +172,9 @@ bool GetNameForDecl(const clang::VarDecl& decl,
name = CamelCaseToUnderscoreCase(original_name);
}
- if (decl.isStaticDataMember()) {
+ // Static members end with _ just like other members, but constants should
+ // not.
+ if (!is_const && decl.isStaticDataMember()) {
name += '_';
}
diff --git a/tools/clang/rewrite_to_chrome_style/tests/constants-expected.cc b/tools/clang/rewrite_to_chrome_style/tests/constants-expected.cc
index e6b233b..1136d2f 100644
--- a/tools/clang/rewrite_to_chrome_style/tests/constants-expected.cc
+++ b/tools/clang/rewrite_to_chrome_style/tests/constants-expected.cc
@@ -17,11 +17,11 @@ const float kPi = 3.141592654;
class C {
public:
// Static class constants.
- static const int kUsefulConstant_ = 8;
+ static const int kUsefulConstant = 8;
// Note: s_ prefix should not be retained.
- static const int kStaticConstant_ = 9;
+ static const int kStaticConstant = 9;
// Note: m_ prefix should not be retained even though the proper prefix is s_.
- static const int kSuperNumber_ = 42;
+ static const int kSuperNumber = 42;
// Not a constant even though it has static storage duration.
static const char* current_event_;