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

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

Issue 1782293003: rewrite_to_chrome_style: Blacklist InspectorAgent::disable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | no next file » | 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 97090ca23207547fdaf4949d1d958388e340d129..efecb8275a1971f671225e7102491cc4a75a3296 100644
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
@@ -87,6 +87,18 @@ AST_MATCHER_P(clang::CXXCtorInitializer,
InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
}
+bool IsMethodOverrideOf(const clang::CXXMethodDecl& decl,
+ const char* class_name) {
+ if (decl.getParent()->getQualifiedNameAsString() == class_name)
+ return true;
+ for (auto it = decl.begin_overridden_methods();
+ it != decl.end_overridden_methods(); ++it) {
+ if (IsMethodOverrideOf(**it, class_name))
+ return true;
+ }
+ return false;
+}
+
bool IsBlacklistedMethod(const clang::CXXMethodDecl& decl) {
if (decl.isStatic())
return false;
@@ -104,12 +116,21 @@ bool IsBlacklistedMethod(const clang::CXXMethodDecl& decl) {
// Iterator methods shouldn't be renamed to work with stl and range-for
// loops.
std::string ret_type = decl.getReturnType().getAsString();
- if (ret_type.find("iterator") == std::string::npos &&
- ret_type.find("Iterator") == std::string::npos)
- return false;
- static const char* kIteratorBlacklist[] = {"begin", "end", "rbegin", "rend"};
- for (const auto& b : kIteratorBlacklist) {
- if (name == b)
+ if (ret_type.find("iterator") != std::string::npos ||
+ ret_type.find("Iterator") != std::string::npos) {
+ static const char* kIteratorBlacklist[] = {"begin", "end", "rbegin",
+ "rend"};
+ for (const auto& b : kIteratorBlacklist) {
+ if (name == b)
+ 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
+ // it or split this up. So don't rename it at all.
+ if (name.equals("disable")) {
+ if (IsMethodOverrideOf(decl, "blink::InspectorAgent"))
dcheng 2016/03/11 02:01:17 Nit: &&
danakj 2016/03/11 02:08:42 Ohh ya :) Done.
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698