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

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

Issue 2601063002: Blacklisting of method names coming from std library. (Closed)
Patch Set: Also blacklisting "insert". Created 4 years 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 | « no previous file | tools/clang/rewrite_to_chrome_style/tests/function-templates-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 cd4a279e73aa139b96629463a064a0a6e42ee5e0..247e3b5f5f582f4a8c1aedf78a40893da04ad53a 100644
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
@@ -208,6 +208,12 @@ bool IsMethodOverrideOf(const clang::CXXMethodDecl& decl,
}
bool IsBlacklistedFunctionName(llvm::StringRef name) {
+ // https://crbug.com/672902: Method names with an underscore are typically
+ // mimicked after std library / are typically not originating from Blink.
+ // Do not rewrite such names (like push_back, emplace_back, etc.).
+ if (name.find('_') != llvm::StringRef::npos)
+ return true;
+
// https://crbug.com/677166: Have to avoid renaming |hash| -> |Hash| to avoid
// colliding with a struct already named |Hash|.
return name == "hash";
@@ -225,6 +231,10 @@ bool IsBlacklistedInstanceMethodName(llvm::StringRef name) {
// 2. They (begin+end) are used in range-based for syntax sugar
// - for (auto x : foo) { ... } // <- foo.begin() will be called.
"begin", "end", "rbegin", "rend", "lock", "unlock", "try_lock",
+
+ // https://crbug.com/672902: Should not rewrite names that mimick methods
+ // from std library.
+ "back", "empty", "erase", "front", "insert",
};
for (const auto& b : kBlacklistedNames) {
if (name == b)
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/function-templates-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698