summaryrefslogtreecommitdiffstats
path: root/tools/clang
diff options
context:
space:
mode:
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_;