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

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

Issue 1753563003: rewrite_to_chrome_style: Improve naming of iterator and type traits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clang-structs: reviews Created 4 years, 9 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 namespace blink { 5 namespace blink {
6 6
7 class MyIterator {};
8 using my_iterator = MyIterator;
dcheng 2016/03/02 00:35:19 I think the problem case I was considering is if y
dcheng 2016/03/02 00:37:00 Or perhaps something like this: template<typename
9
7 class Task { 10 class Task {
8 public: 11 public:
9 // Already style-compliant methods shouldn't change. 12 // Already style-compliant methods shouldn't change.
10 void OutputDebugString() {} 13 void OutputDebugString() {}
11 14
12 // Tests that the declarations for methods are updated. 15 // Tests that the declarations for methods are updated.
13 void DoTheWork(); 16 void DoTheWork();
14 // Overload to test using declarations that introduce multiple shadow 17 // Overload to test using declarations that introduce multiple shadow
15 // declarations. 18 // declarations.
16 void DoTheWork(int); 19 void DoTheWork(int);
17 virtual void ReallyDoTheWork() = 0; 20 virtual void ReallyDoTheWork() = 0;
18 21
19 // Note: this is purposely copyable and assignable, to make sure the Clang 22 // Note: this is purposely copyable and assignable, to make sure the Clang
20 // tool doesn't try to emit replacements for things that aren't explicitly 23 // tool doesn't try to emit replacements for things that aren't explicitly
21 // written. 24 // written.
22 25
23 // Overloaded operators should not be rewritten. 26 // Overloaded operators should not be rewritten.
24 Task& operator++() { return *this; } 27 Task& operator++() { return *this; }
25 28
26 // Conversion functions should not be rewritten. 29 // Conversion functions should not be rewritten.
27 explicit operator int() const { return 42; } 30 explicit operator int() const { return 42; }
28 31
29 // These are special functions that we don't rename so that range-based 32 // These are special functions that we don't rename so that range-based
30 // for loops and STL things work. 33 // for loops and STL things work.
31 void begin() {} 34 MyIterator begin() {}
32 void end() {} 35 my_iterator end() {}
33 void rbegin() {} 36 my_iterator rbegin() {}
34 void rend() {} 37 MyIterator rend() {}
35 // The trace() method is used by Oilpan, we shouldn't rename it. 38 // The trace() method is used by Oilpan, we shouldn't rename it.
36 void trace() {} 39 void trace() {}
37 // These are used by std::unique_lock and std::lock_guard. 40 // These are used by std::unique_lock and std::lock_guard.
38 void lock() {} 41 void lock() {}
39 void unlock() {} 42 void unlock() {}
40 void try_lock() {} 43 void try_lock() {}
41 }; 44 };
42 45
43 class Other { 46 class Other {
44 // Static begin/end/trace don't count, and should be renamed. 47 // Static begin/end/trace don't count, and should be renamed.
45 static void Begin() {} 48 static MyIterator Begin() {}
46 static void End() {} 49 static my_iterator End() {}
47 static void Trace() {} 50 static void Trace() {}
48 static void Lock() {} 51 static void Lock() {}
49 }; 52 };
50 53
54 class NonIterators {
55 // begin()/end() and friends are renamed if they don't return an iterator.
56 void Begin() {}
57 int End() { return 0; }
58 void Rbegin() {}
59 int Rend() { return 0; }
60 };
61
51 // Test that the actual method definition is also updated. 62 // Test that the actual method definition is also updated.
52 void Task::DoTheWork() { 63 void Task::DoTheWork() {
53 ReallyDoTheWork(); 64 ReallyDoTheWork();
54 } 65 }
55 66
56 } // namespace blink 67 } // namespace blink
57 68
58 // Test that overrides from outside the Blink namespace are also updated. 69 // Test that overrides from outside the Blink namespace are also updated.
59 class BovineTask : public blink::Task { 70 class BovineTask : public blink::Task {
60 public: 71 public:
(...skipping 12 matching lines...) Expand all
73 ReallyDoTheWork(); 84 ReallyDoTheWork();
74 } 85 }
75 86
76 // Finally, test that method pointers are also updated. 87 // Finally, test that method pointers are also updated.
77 void F() { 88 void F() {
78 void (blink::Task::*p1)() = &blink::Task::DoTheWork; 89 void (blink::Task::*p1)() = &blink::Task::DoTheWork;
79 void (blink::Task::*p2)() = &BovineTask::DoTheWork; 90 void (blink::Task::*p2)() = &BovineTask::DoTheWork;
80 void (blink::Task::*p3)() = &blink::Task::ReallyDoTheWork; 91 void (blink::Task::*p3)() = &blink::Task::ReallyDoTheWork;
81 void (BovineTask::*p4)() = &BovineTask::ReallyDoTheWork; 92 void (BovineTask::*p4)() = &BovineTask::ReallyDoTheWork;
82 } 93 }
94
95 namespace blink {
96
97 struct StructInBlink {
98 // Structs in blink should rename their methods to capitals.
99 bool Function() { return true; }
100 };
101
102 } // namespace blink
103
104 namespace WTF {
105
106 struct StructInWTF {
107 // Structs in WTF should rename their methods to capitals.
108 bool Function() { return true; }
109 };
110
111 } // namespace WTF
112
113 void F2() {
114 blink::StructInBlink b;
115 b.Function();
116 WTF::StructInWTF w;
117 w.Function();
118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698