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 dddccd1741bb968b0c99fec10af2bda8a3a5ec5a..9679c9ff5d80480c4e56aebd53648424f53ffbbb 100644 |
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
@@ -342,8 +342,21 @@ bool GetNameForDecl(const clang::VarDecl& decl, |
StringRef original_name = decl.getName(); |
// Nothing to do for unnamed parameters. |
- if (clang::isa<clang::ParmVarDecl>(decl) && original_name.empty()) |
- return false; |
+ if (clang::isa<clang::ParmVarDecl>(decl)) { |
+ if (original_name.empty()) |
+ return false; |
+ |
+ // Check if |decl| really covers text of |original_name|. This might not be |
+ // true when specializing a templatized class that had an unnamed parameter |
+ // in one of method declarations. |
dcheng
2016/08/25 04:08:51
Let's file an upstream bug for this with the test
Łukasz Anforowicz
2016/08/25 23:32:33
Done: https://llvm.org/bugs/show_bug.cgi?id=29145
|
+ clang::SourceLocation loc = decl.getLocation(); |
+ clang::CharSourceRange range = clang::CharSourceRange::getTokenRange(loc); |
+ StringRef old_text = clang::Lexer::getSourceText( |
+ range, context.getSourceManager(), context.getLangOpts()); |
+ if (!loc.isMacroID() && old_text != original_name) { |
dcheng
2016/08/25 04:08:52
Add a comment why we want to ignore SourceLocation
Łukasz Anforowicz
2016/08/25 23:32:33
I've started using spelling location in the latest
|
+ return false; |
+ } |
+ } |
// static class members match against VarDecls. Blink style dictates that |
// these should be prefixed with `s_`, so strip that off. Also check for `m_` |