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

Unified Diff: tools/clang/rewrite_to_chrome_style/tests/methods-original.cc

Issue 2608443002: Blacklisting renaming of "hash" in case of static methods and functions. (Closed)
Patch Set: Making IsBlacklistedMethodName a free function again. 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 | « tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc ('k') | 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/tests/methods-original.cc
diff --git a/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc b/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc
index 3dd8b73aa971102731c89fb487d1b9bd40e29d93..4279c1dd0f3e4f37bb58ec06352f678799e7b36b 100644
--- a/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc
+++ b/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc
@@ -239,6 +239,39 @@ class PaintLayerStackingNode {
} // namespace get_prefix_vs_inheritance
+namespace blacklisting_of_method_and_function_names {
+
+class Foo {
+ // Expecting |swap| method to be renamed to |Swap| - we blacklist renaming of
+ // |swap| *function*, because it needs to have the same casing as std::swap,
+ // so that ADL can kick-in and pull it from another namespace depending on the
+ // bargument. We have a choice to rename or not rename |swap| *methods* - we
+ // chose to rename to be consistent (i.e. we rename |clear| -> |Clear|) and
+ // because Google C++ Styke Guide uses "Swap" in examples.
+ void swap() {}
+ static void swap(Foo& x, Foo& y) {}
+
+ // We don't rename |begin|, so that <algorithms> and other templates that
+ // expect |begin|, |end|, etc. continue to work. This is only necessary
+ // for instance methods - renaming static methods and funcitons is okay.
+ void begin() {}
+ 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(); }
+};
+
+void begin(int x) {}
+int hash(int x) {
+ return 123 * x;
+}
+void swap(Foo& x, Foo& y) {}
+
+} // blacklisting_of_method_and_function_names
+
} // namespace blink
namespace WTF {
« no previous file with comments | « tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698