Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp

Issue 2246263002: Skip parameter replacements where old text != old name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak a comment so that it refers to the clang bug. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « docs/clang_tool_refactoring.md ('k') | tools/clang/rewrite_to_chrome_style/tests/template-expected.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_`
« no previous file with comments | « docs/clang_tool_refactoring.md ('k') | tools/clang/rewrite_to_chrome_style/tests/template-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698