Commit 0915b0fa authored by danakj's avatar danakj Committed by Commit bot

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}
parent b3313230
......@@ -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 += '_';
}
......
......@@ -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_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment