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

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

Issue 2601513005: Don't walk inheritance chain of return type to make renaming decisions. (Closed)
Patch Set: LayoutObject -> LayoutObjectFoo (to avoid testing ShouldPrefixFunctionName) 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 3374ea29ea6bd6ab8c3f0b796c90c6e5683384c2..b0b2e8555451a45145aec45147135fc362f48c6b 100644
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
@@ -344,12 +344,14 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) {
"error",
"fileUtilities",
"font",
+ "frame",
"frameBlameContext",
"iconURL",
"inputMethodController",
"inputType",
"layout",
"layoutBlock",
+ "layoutObject",
"layoutSize",
"length",
"lineCap",
@@ -364,6 +366,8 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) {
"path",
"processingInstruction",
"readyState",
+ "response",
+ "sandboxSupport",
"screenInfo",
"scrollAnimator",
"settings",
@@ -408,9 +412,7 @@ bool GetNameForDecl(const clang::FunctionDecl& decl,
// hasString matches the type as spelled (Bar above).
hasString(name),
// hasDeclaration matches resolved type (Foo or DerivedFoo above).
- hasDeclaration(namedDecl(hasName(name))),
- hasDeclaration(
- cxxRecordDecl(isDerivedFrom(namedDecl(hasName(name)))))));
+ hasDeclaration(namedDecl(hasName(name)))));
// |type_containing_same_name_as_function| matcher will match all of the
// return types below:
@@ -423,7 +425,15 @@ bool GetNameForDecl(const clang::FunctionDecl& decl,
// https://crbug.com/582312: Prepend "Get" if method name conflicts with
// return type.
auto conflict_matcher = functionDecl(anyOf(
- returns(type_containing_same_name_as_function),
+ // For functions and non-virtual or base method implementations just
+ // compare with the immediate return type.
+ functionDecl(returns(type_containing_same_name_as_function),
+ unless(cxxMethodDecl(isOverride()))),
+ // For methods that override one or more methods, compare with the return
+ // type of the *base* methods.
+ cxxMethodDecl(isOverride(), forEachOverridden(returns(
+ type_containing_same_name_as_function))),
+ // And also check hardcoded list of function names to prefix with "Get".
shouldPrefixFunctionName()));
if (IsMatching(conflict_matcher, decl, context))
name = "Get" + name;
« 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