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

Side by Side Diff: tools/clang/rewrite_to_chrome_style/tests/methods-original.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: test 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 = char*;
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++() { 27 Task& operator++() {
25 return *this; 28 return *this;
26 } 29 }
27 30
28 // Conversion functions should not be rewritten. 31 // Conversion functions should not be rewritten.
29 explicit operator int() const { 32 explicit operator int() const {
30 return 42; 33 return 42;
31 } 34 }
32 35
33 // These are special functions that we don't rename so that range-based 36 // These are special functions that we don't rename so that range-based
34 // for loops and STL things work. 37 // for loops and STL things work.
35 void begin() {} 38 MyIterator begin() {}
36 void end() {} 39 my_iterator end() {}
37 void rbegin() {} 40 my_iterator rbegin() {}
38 void rend() {} 41 MyIterator rend() {}
39 // The trace() method is used by Oilpan, we shouldn't rename it. 42 // The trace() method is used by Oilpan, we shouldn't rename it.
40 void trace() {} 43 void trace() {}
41 // These are used by std::unique_lock and std::lock_guard. 44 // These are used by std::unique_lock and std::lock_guard.
42 void lock() {} 45 void lock() {}
43 void unlock() {} 46 void unlock() {}
44 void try_lock() {} 47 void try_lock() {}
45 }; 48 };
46 49
47 class Other { 50 class Other {
48 // Static begin/end/trace don't count, and should be renamed. 51 // Static begin/end/trace don't count, and should be renamed.
49 static void begin() {} 52 static MyIterator begin() {}
50 static void end() {} 53 static my_iterator end() {}
51 static void trace() {} 54 static void trace() {}
52 static void lock() {} 55 static void lock() {}
53 }; 56 };
54 57
58 class NonIterators {
59 // begin()/end() and friends are renamed if they don't return an iterator.
60 void begin() {}
61 int end() { return 0; }
62 void rbegin() {}
63 int rend() { return 0; }
64 };
65
55 // Test that the actual method definition is also updated. 66 // Test that the actual method definition is also updated.
56 void Task::doTheWork() { 67 void Task::doTheWork() {
57 reallyDoTheWork(); 68 reallyDoTheWork();
58 } 69 }
59 70
60 } // namespace blink 71 } // namespace blink
61 72
62 // Test that overrides from outside the Blink namespace are also updated. 73 // Test that overrides from outside the Blink namespace are also updated.
63 class BovineTask : public blink::Task { 74 class BovineTask : public blink::Task {
64 public: 75 public:
(...skipping 12 matching lines...) Expand all
77 reallyDoTheWork(); 88 reallyDoTheWork();
78 } 89 }
79 90
80 // Finally, test that method pointers are also updated. 91 // Finally, test that method pointers are also updated.
81 void F() { 92 void F() {
82 void (blink::Task::*p1)() = &blink::Task::doTheWork; 93 void (blink::Task::*p1)() = &blink::Task::doTheWork;
83 void (blink::Task::*p2)() = &BovineTask::doTheWork; 94 void (blink::Task::*p2)() = &BovineTask::doTheWork;
84 void (blink::Task::*p3)() = &blink::Task::reallyDoTheWork; 95 void (blink::Task::*p3)() = &blink::Task::reallyDoTheWork;
85 void (BovineTask::*p4)() = &BovineTask::reallyDoTheWork; 96 void (BovineTask::*p4)() = &BovineTask::reallyDoTheWork;
86 } 97 }
98
99 namespace blink {
100
101 struct StructInBlink {
102 // Structs in blink should rename their methods to capitals.
103 bool function() { return true; }
104 };
105
106 } // namespace blink
107
108 namespace WTF {
109
110 struct StructInWTF {
111 // Structs in WTF should rename their methods to capitals.
112 bool function() { return true; }
113 };
114
115 } // namespace WTF
116
117 void F2() {
118 blink::StructInBlink b;
119 b.function();
120 WTF::StructInWTF w;
121 w.function();
122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698