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

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: Trying to remove code duplication. 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 class LayoutObject {}; 220 class LayoutObject {};
221 class LayoutBoxModelObject : public LayoutObject {}; 221 class LayoutBoxModelObject : public LayoutObject {};
222 class PaintLayerStackingNode { 222 class PaintLayerStackingNode {
223 public: 223 public:
224 // |layoutObject| should be renamed to |GetLayoutObject|. 224 // |layoutObject| should be renamed to |GetLayoutObject|.
225 LayoutBoxModelObject* GetLayoutObject() { return nullptr; } 225 LayoutBoxModelObject* GetLayoutObject() { return nullptr; }
226 }; 226 };
227 227
228 } // namespace get_prefix_vs_inheritance 228 } // namespace get_prefix_vs_inheritance
229 229
230 namespace blacklisting_of_method_and_function_names {
231
232 class Foo {
233 // Expecting |swap| method to be renamed to |Swap| - we blacklist renaming of
234 // |swap| *function*, because it needs to have the same casing as std::swap,
235 // so that ADL can kick-in and pull it from another namespace depending on the
236 // bargument. We have a choice to rename or not rename |swap| *methods* - we
237 // chose to rename to be consistent (i.e. we rename |clear| -> |Clear|) and
238 // because Google C++ Styke Guide uses "Swap" in examples.
239 void Swap() {}
240 static void Swap(Foo& x, Foo& y) {}
241
242 // We don't rename |begin|, so that <algorithms> and other templates that
243 // expect |begin|, |end|, etc. continue to work. This is only necessary
244 // for instance methods - renaming static methods and funcitons is okay.
245 void begin() {}
246 static void Begin(int x) {}
247
248 // https://crbug.com/677166: We blacklist renaming of |hash|, because it
249 // collides with a struct named Hash. Blacklisting therefore should be broad
250 // and should cover both instance and static methods as well as functions.
251 int hash() const { return 123; }
252 static int hash(const Foo& x) { return x.hash(); }
253 };
254
255 void Begin(int x) {}
256 int hash(int x) {
257 return 123 * x;
258 }
259 void swap(Foo& x, Foo& y) {}
260
261 } // blacklisting_of_method_and_function_names
262
230 } // namespace blink 263 } // namespace blink
231 264
232 namespace WTF { 265 namespace WTF {
233 266
234 struct StructInWTF { 267 struct StructInWTF {
235 // Structs in WTF should rename their methods to capitals. 268 // Structs in WTF should rename their methods to capitals.
236 bool Function() { return true; } 269 bool Function() { return true; }
237 }; 270 };
238 271
239 } // namespace WTF 272 } // namespace WTF
(...skipping 19 matching lines...) Expand all
259 static void Method(); 292 static void Method();
260 }; 293 };
261 294
262 } // namespace internal 295 } // namespace internal
263 296
264 } // namespace blink 297 } // namespace blink
265 298
266 // https://crbug.com/640688 - need to rewrite method name below. 299 // https://crbug.com/640688 - need to rewrite method name below.
267 void blink::ClassDeclaredInsideBlink::MethodDefinedOutsideBlink() {} 300 void blink::ClassDeclaredInsideBlink::MethodDefinedOutsideBlink() {}
268 void blink::internal::InternalClass::Method() {} 301 void blink::internal::InternalClass::Method() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698