Commit 0020d5c9 authored by nasko's avatar nasko Committed by Commit bot

Update methods requiring Get prefix to avoid collisions with Blink rewrite.

This CL adds a few more methods that cause name collisions when Blink
is rewritten to match Chromium style. In addition, it removes the hash
method from the blacklist.

BUG=582312, 677166

Review-Url: https://codereview.chromium.org/2608423003
Cr-Commit-Position: refs/heads/master@{#441429}
parent d4d76b8d
...@@ -214,9 +214,7 @@ bool IsBlacklistedFunctionName(llvm::StringRef name) { ...@@ -214,9 +214,7 @@ bool IsBlacklistedFunctionName(llvm::StringRef name) {
if (name.find('_') != llvm::StringRef::npos) if (name.find('_') != llvm::StringRef::npos)
return true; return true;
// https://crbug.com/677166: Have to avoid renaming |hash| -> |Hash| to avoid return false;
// colliding with a struct already named |Hash|.
return name == "hash";
} }
bool IsBlacklistedFreeFunctionName(llvm::StringRef name) { bool IsBlacklistedFreeFunctionName(llvm::StringRef name) {
...@@ -358,8 +356,8 @@ AST_MATCHER_P(clang::QualType, hasString, std::string, ExpectedString) { ...@@ -358,8 +356,8 @@ AST_MATCHER_P(clang::QualType, hasString, std::string, ExpectedString) {
} }
bool ShouldPrefixFunctionName(const std::string& old_method_name) { bool ShouldPrefixFunctionName(const std::string& old_method_name) {
// Methods that are named similarily to a type - they should be prefixed // Functions that are named similarily to a type - they should be prefixed
// with a "get" prefix. // with a "Get" prefix.
static const char* kConflictingMethods[] = { static const char* kConflictingMethods[] = {
"animationWorklet", "animationWorklet",
"audioWorklet", "audioWorklet",
...@@ -378,6 +376,9 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) { ...@@ -378,6 +376,9 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) {
"font", "font",
"frame", "frame",
"frameBlameContext", "frameBlameContext",
"frontend",
"hash",
"heapObjectHeader",
"iconURL", "iconURL",
"inputMethodController", "inputMethodController",
"inputType", "inputType",
...@@ -387,8 +388,12 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) { ...@@ -387,8 +388,12 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) {
"layoutSize", "layoutSize",
"length", "length",
"lineCap", "lineCap",
"lineEndings",
"lineJoin", "lineJoin",
"listItems",
"matchedProperties", "matchedProperties",
"midpointState",
"mouseEvent",
"name", "name",
"navigationType", "navigationType",
"node", "node",
...@@ -398,6 +403,8 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) { ...@@ -398,6 +403,8 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) {
"path", "path",
"processingInstruction", "processingInstruction",
"readyState", "readyState",
"relList",
"resource",
"response", "response",
"sandboxSupport", "sandboxSupport",
"screenInfo", "screenInfo",
...@@ -406,13 +413,18 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) { ...@@ -406,13 +413,18 @@ bool ShouldPrefixFunctionName(const std::string& old_method_name) {
"signalingState", "signalingState",
"state", "state",
"string", "string",
"styleSheet",
"text", "text",
"textAlign", "textAlign",
"textBaseline", "textBaseline",
"theme", "theme",
"thread",
"timing", "timing",
"topLevelBlameContext", "topLevelBlameContext",
"vector",
"widget", "widget",
"wordBoundaries",
"wrapperTypeInfo",
}; };
for (const auto& conflicting_method : kConflictingMethods) { for (const auto& conflicting_method : kConflictingMethods) {
if (old_method_name == conflicting_method) if (old_method_name == conflicting_method)
......
...@@ -253,12 +253,6 @@ class Foo { ...@@ -253,12 +253,6 @@ class Foo {
void begin() {} void begin() {}
static void Begin(int x) {} static void Begin(int x) {}
// https://crbug.com/677166: We blacklist renaming of |hash|, because it
// collides with a struct named Hash. Blacklisting therefore should be broad
// and should cover both instance and static methods as well as functions.
int hash() const { return 123; }
static int hash(const Foo& x) { return x.hash(); }
// https://crbug.com672902: std-like names should not be rewritten. // https://crbug.com672902: std-like names should not be rewritten.
void emplace_back(int x) {} void emplace_back(int x) {}
void insert(int x) {} void insert(int x) {}
...@@ -270,9 +264,6 @@ class Foo { ...@@ -270,9 +264,6 @@ class Foo {
}; };
void Begin(int x) {} void Begin(int x) {}
int hash(int x) {
return 123 * x;
}
void swap(Foo& x, Foo& y) {} void swap(Foo& x, Foo& y) {}
} // blacklisting_of_method_and_function_names } // blacklisting_of_method_and_function_names
......
...@@ -257,12 +257,6 @@ class Foo { ...@@ -257,12 +257,6 @@ class Foo {
void begin() {} void begin() {}
static void begin(int x) {} static void begin(int x) {}
// https://crbug.com/677166: We blacklist renaming of |hash|, because it
// collides with a struct named Hash. Blacklisting therefore should be broad
// and should cover both instance and static methods as well as functions.
int hash() const { return 123; }
static int hash(const Foo& x) { return x.hash(); }
// https://crbug.com672902: std-like names should not be rewritten. // https://crbug.com672902: std-like names should not be rewritten.
void emplace_back(int x) {} void emplace_back(int x) {}
void insert(int x) {} void insert(int x) {}
...@@ -274,9 +268,6 @@ class Foo { ...@@ -274,9 +268,6 @@ class Foo {
}; };
void begin(int x) {} void begin(int x) {}
int hash(int x) {
return 123 * x;
}
void swap(Foo& x, Foo& y) {} void swap(Foo& x, Foo& y) {}
} // blacklisting_of_method_and_function_names } // blacklisting_of_method_and_function_names
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment