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

Side by Side 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: Addressed CR feedback + shuffled code around a bit. Created 3 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gen/thing.h" 5 #include "gen/thing.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 8
9 class InterfaceOutsideOfBlink { 9 class InterfaceOutsideOfBlink {
10 public: 10 public:
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 class LayoutObject {}; 224 class LayoutObject {};
225 class LayoutBoxModelObject : public LayoutObject {}; 225 class LayoutBoxModelObject : public LayoutObject {};
226 class PaintLayerStackingNode { 226 class PaintLayerStackingNode {
227 public: 227 public:
228 // |layoutObject| should be renamed to |GetLayoutObject|. 228 // |layoutObject| should be renamed to |GetLayoutObject|.
229 LayoutBoxModelObject* layoutObject() { return nullptr; } 229 LayoutBoxModelObject* layoutObject() { return nullptr; }
230 }; 230 };
231 231
232 } // namespace get_prefix_vs_inheritance 232 } // namespace get_prefix_vs_inheritance
233 233
234 namespace blacklisting_of_method_and_function_names {
235
236 class Foo {
237 // Expecting |swap| method to be renamed to |Swap| - we blacklist renaming of
238 // |swap| *function*, because it needs to have the same casing as std::swap,
239 // so that ADL can kick-in and pull it from another namespace depending on the
240 // bargument. We have a choice to rename or not rename |swap| *methods* - we
241 // chose to rename to be consistent (i.e. we rename |clear| -> |Clear|) and
242 // because Google C++ Styke Guide uses "Swap" in examples.
243 void swap() {}
244 static void swap(Foo& x, Foo& y) {}
245
246 // We don't rename |begin|, so that <algorithms> and other templates that
247 // expect |begin|, |end|, etc. continue to work. This is only necessary
248 // for instance methods - renaming static methods and funcitons is okay.
249 void begin() {}
250 static void begin(int x) {}
251
252 // https://crbug.com/677166: We blacklist renaming of |hash|, because it
253 // collides with a struct named Hash. Blacklisting therefore should be broad
254 // and should cover both instance and static methods as well as functions.
255 int hash() const { return 123; }
256 static int hash(const Foo& x) { return x.hash(); }
257 };
258
259 void begin(int x) {}
260 int hash(int x) {
261 return 123 * x;
262 }
263 void swap(Foo& x, Foo& y) {}
264
265 } // blacklisting_of_method_and_function_names
266
234 } // namespace blink 267 } // namespace blink
235 268
236 namespace WTF { 269 namespace WTF {
237 270
238 struct StructInWTF { 271 struct StructInWTF {
239 // Structs in WTF should rename their methods to capitals. 272 // Structs in WTF should rename their methods to capitals.
240 bool function() { return true; } 273 bool function() { return true; }
241 }; 274 };
242 275
243 } // namespace WTF 276 } // namespace WTF
(...skipping 19 matching lines...) Expand all
263 static void method(); 296 static void method();
264 }; 297 };
265 298
266 } // namespace internal 299 } // namespace internal
267 300
268 } // namespace blink 301 } // namespace blink
269 302
270 // https://crbug.com/640688 - need to rewrite method name below. 303 // https://crbug.com/640688 - need to rewrite method name below.
271 void blink::ClassDeclaredInsideBlink::methodDefinedOutsideBlink() {} 304 void blink::ClassDeclaredInsideBlink::methodDefinedOutsideBlink() {}
272 void blink::internal::InternalClass::method() {} 305 void blink::internal::InternalClass::method() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698