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..596c1582e84f408e7836bdd418fc5227085ceea4 100644 |
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp |
@@ -342,8 +342,20 @@ 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|. See also |
+ // https://llvm.org/bugs/show_bug.cgi?id=29145 |
dcheng
2016/08/26 20:28:02
Perhaps describe the actual bug a bit here: a meth
Łukasz Anforowicz
2016/08/26 22:39:51
Done.
|
+ clang::SourceLocation loc = |
+ context.getSourceManager().getSpellingLoc(decl.getLocation()); |
+ clang::CharSourceRange range = clang::CharSourceRange::getTokenRange(loc); |
+ StringRef old_text = clang::Lexer::getSourceText( |
+ range, context.getSourceManager(), context.getLangOpts()); |
+ if (old_text != original_name) |
+ 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_` |