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

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: The fix fixes the new regression test. 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 9ae3201a4c2b0964141b30d3207de19373c716b6..e650e32bfc2baff67b14d094da0b0e73c64446a9 100644
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
@@ -523,6 +523,15 @@ class RewriterBase : public MatchFinder::MatchCallback {
*result.Nodes.getNodeAs<TargetNode>(
TargetNodeTraits<TargetNode>::GetName()));
clang::CharSourceRange range = clang::CharSourceRange::getTokenRange(loc);
+
+ // Check if |range| really covers text of |old_name|. This might not be
+ // true when specializing a templatized class that had an unnamed parameter
+ // in one of method declarations.
+ StringRef old_text = clang::Lexer::getSourceText(
+ range, *result.SourceManager, result.Context->getLangOpts());
+ if (!loc.isMacroID() && old_text != old_name)
+ return;
+
Łukasz Anforowicz 2016/08/15 23:05:08 The new code makes the new regression test pass.
dcheng 2016/08/25 04:08:51 How were you printing out this diagnostic info? Re
Łukasz Anforowicz 2016/08/25 23:32:33 Thanks for bringing up "spelling location". I can
replacements_->emplace(*result.SourceManager, range, new_name);
replacement_names_.emplace(old_name.str(), std::move(new_name));
}
« 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