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

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

Issue 2580773003: Blacklist method names without considering static-vs-instance. (Closed)
Patch Set: Stop blacklisting the |trace| method instead. 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/methods-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 97d9ebd309706e2e64d64d88f1452ea64400d3ed..d308f5e1e046cf87995fe7c529d68ed28058f9df 100644
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
@@ -218,20 +218,25 @@ bool IsBlacklistedFunction(const clang::FunctionDecl& decl) {
return decl.getName() == "swap";
}
+bool IsBlacklistedMethodName(llvm::StringRef name) {
+ static const char* kBlacklistedNames[] = {
+ "lock", "unlock", "try_lock",
+ "begin", "end", "rbegin", "rend",
+ };
+ for (const auto& b : kBlacklistedNames) {
+ if (name == b)
+ return true;
+ }
+ return false;
+}
+
bool IsBlacklistedMethod(const clang::CXXMethodDecl& decl) {
if (decl.isStatic())
return false;
clang::StringRef name = decl.getName();
-
- // These methods should never be renamed.
- static const char* kBlacklistMethods[] = {"trace", "traceImpl", "lock",
- "unlock", "try_lock", "begin",
- "end", "rbegin", "rend"};
- for (const auto& b : kBlacklistMethods) {
- if (name == b)
+ if (IsBlacklistedMethodName(name))
return true;
- }
// Subclasses of InspectorAgent will subclass "disable()" from both blink and
// from gen/, which is problematic, but DevTools folks don't want to rename
@@ -243,21 +248,6 @@ bool IsBlacklistedMethod(const clang::CXXMethodDecl& decl) {
return false;
}
-bool IsBlacklistedFunctionOrMethodName(llvm::StringRef name) {
- static const char* kBlacklistedNames[] = {
- // From IsBlacklistedFunction:
- "swap",
- // From IsBlacklistedMethod:
- "trace", "traceImpl", "lock", "unlock", "try_lock", "begin", "end",
- "rbegin", "rend", "disable",
- };
- for (const auto& b : kBlacklistedNames) {
- if (name == b)
- return true;
- }
- return false;
-}
-
AST_MATCHER(clang::FunctionDecl, isBlacklistedFunction) {
return IsBlacklistedFunction(Node);
}
@@ -826,7 +816,7 @@ class UnresolvedRewriterBase : public RewriterBase<TargetNode> {
// |T::myMethod(...)| -> |T::MyMethod(...)|.
if ((old_name.find('_') == std::string::npos) && IsCallee(node, context) &&
- !IsBlacklistedFunctionOrMethodName(old_name)) {
+ !IsBlacklistedMethodName(old_name)) {
new_name = old_name;
new_name[0] = clang::toUppercase(old_name[0]);
return true;
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698