Index: tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
index 9123f5527b8b6411a510dda0371e251cb9248078..4f3badd740e70beea4c876ba33b6391c64990089 100644 |
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
@@ -59,7 +59,10 @@ constexpr char kBlinkStaticMemberPrefix[] = "s_"; |
bool GetNameForDecl(const clang::FunctionDecl& decl, |
const clang::ASTContext& context, |
std::string& name) { |
- name = decl.getNameAsString(); |
+ // If there's no name to change, return. |
+ if (!decl.getIdentifier()) |
+ return false; |
+ StringRef original_name = decl.getName(); |
if (const auto* method = clang::dyn_cast<const clang::CXXMethodDecl>(&decl)) { |
if (!method->isStatic()) { |
@@ -67,12 +70,13 @@ bool GetNameForDecl(const clang::FunctionDecl& decl, |
static const char* kBlacklist[] = {"begin", "end", "rbegin", "rend", |
"trace"}; |
for (const auto& b : kBlacklist) { |
- if (name == b) |
+ if (original_name == b) |
return false; |
} |
} |
} |
+ name = original_name.str(); |
name[0] = clang::toUppercase(name[0]); |
return true; |
} |
@@ -114,6 +118,9 @@ std::string CamelCaseToUnderscoreCase(StringRef input) { |
bool GetNameForDecl(const clang::FieldDecl& decl, |
const clang::ASTContext& context, |
std::string& name) { |
+ // If there's no name to change, return. |
+ if (!decl.getIdentifier()) |
+ return false; |
StringRef original_name = decl.getName(); |
// Blink style field names are prefixed with `m_`. If this prefix isn't |
// present, assume it's already been converted to Google style. |
@@ -158,6 +165,9 @@ bool IsProbablyConst(const clang::VarDecl& decl, |
bool GetNameForDecl(const clang::VarDecl& decl, |
const clang::ASTContext& context, |
std::string& name) { |
+ // If there's no name to change, return. |
+ if (!decl.getIdentifier()) |
dcheng
2016/01/29 01:13:05
Does it makes sense to move this into RewriteBase:
danakj
2016/01/29 01:15:05
Hm ya sure.
|
+ return false; |
StringRef original_name = decl.getName(); |
// Nothing to do for unnamed parameters. |