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

Side by Side Diff: tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc

Issue 2608443002: Blacklisting renaming of "hash" in case of static methods and functions. (Closed)
Patch Set: Making IsBlacklistedMethodName a free function again. Created 3 years, 11 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 public: 228 public:
229 // |layoutObjectFoo| should NOT be renamed to |GetLayoutObjectFoo| (just to 229 // |layoutObjectFoo| should NOT be renamed to |GetLayoutObjectFoo| (just to
230 // |LayoutObjectFoo|) - see the big comment above. We use layoutObject*Foo* 230 // |LayoutObjectFoo|) - see the big comment above. We use layoutObject*Foo*
231 // to test inheritance-related behavior and avoid testing whether method name 231 // to test inheritance-related behavior and avoid testing whether method name
232 // is covered via ShouldPrefixFunctionName. 232 // is covered via ShouldPrefixFunctionName.
233 LayoutBoxModelObject* LayoutObjectFoo() { return nullptr; } 233 LayoutBoxModelObject* LayoutObjectFoo() { return nullptr; }
234 }; 234 };
235 235
236 } // namespace get_prefix_vs_inheritance 236 } // namespace get_prefix_vs_inheritance
237 237
238 namespace blacklisting_of_method_and_function_names {
239
240 class Foo {
241 // Expecting |swap| method to be renamed to |Swap| - we blacklist renaming of
242 // |swap| *function*, because it needs to have the same casing as std::swap,
243 // so that ADL can kick-in and pull it from another namespace depending on the
244 // bargument. We have a choice to rename or not rename |swap| *methods* - we
245 // chose to rename to be consistent (i.e. we rename |clear| -> |Clear|) and
246 // because Google C++ Styke Guide uses "Swap" in examples.
247 void Swap() {}
248 static void Swap(Foo& x, Foo& y) {}
249
250 // We don't rename |begin|, so that <algorithms> and other templates that
251 // expect |begin|, |end|, etc. continue to work. This is only necessary
252 // for instance methods - renaming static methods and funcitons is okay.
253 void begin() {}
254 static void Begin(int x) {}
255
256 // https://crbug.com/677166: We blacklist renaming of |hash|, because it
257 // collides with a struct named Hash. Blacklisting therefore should be broad
258 // and should cover both instance and static methods as well as functions.
259 int hash() const { return 123; }
260 static int hash(const Foo& x) { return x.hash(); }
261 };
262
263 void Begin(int x) {}
264 int hash(int x) {
265 return 123 * x;
266 }
267 void swap(Foo& x, Foo& y) {}
268
269 } // blacklisting_of_method_and_function_names
270
238 } // namespace blink 271 } // namespace blink
239 272
240 namespace WTF { 273 namespace WTF {
241 274
242 struct StructInWTF { 275 struct StructInWTF {
243 // Structs in WTF should rename their methods to capitals. 276 // Structs in WTF should rename their methods to capitals.
244 bool Function() { return true; } 277 bool Function() { return true; }
245 }; 278 };
246 279
247 } // namespace WTF 280 } // namespace WTF
(...skipping 19 matching lines...) Expand all
267 static void Method(); 300 static void Method();
268 }; 301 };
269 302
270 } // namespace internal 303 } // namespace internal
271 304
272 } // namespace blink 305 } // namespace blink
273 306
274 // https://crbug.com/640688 - need to rewrite method name below. 307 // https://crbug.com/640688 - need to rewrite method name below.
275 void blink::ClassDeclaredInsideBlink::MethodDefinedOutsideBlink() {} 308 void blink::ClassDeclaredInsideBlink::MethodDefinedOutsideBlink() {}
276 void blink::internal::InternalClass::Method() {} 309 void blink::internal::InternalClass::Method() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698