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

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

Issue 1765783002: rewrite_to_chrome_style: Rewrite references to members through the class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rewrite-non-member-members: . 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
« no previous file with comments | « tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {}; 7 class MyIterator {};
8 using my_iterator = char*; 8 using my_iterator = char*;
9 9
10 class Task { 10 class Task {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 int end() { return 0; } 61 int end() { return 0; }
62 void rbegin() {} 62 void rbegin() {}
63 int rend() { return 0; } 63 int rend() { return 0; }
64 }; 64 };
65 65
66 // Test that the actual method definition is also updated. 66 // Test that the actual method definition is also updated.
67 void Task::doTheWork() { 67 void Task::doTheWork() {
68 reallyDoTheWork(); 68 reallyDoTheWork();
69 } 69 }
70 70
71 template <typename T>
72 class Testable {
73 public:
74 typedef T Testable::*UnspecifiedBoolType;
75 // This method has a reference to a member in a "member context" and a
76 // "non-member context" to verify both are rewritten.
77 operator UnspecifiedBoolType() { return m_ptr ? &Testable::m_ptr : 0; }
78
79 private:
80 int m_ptr;
81 };
82
71 } // namespace blink 83 } // namespace blink
72 84
73 // Test that overrides from outside the Blink namespace are also updated. 85 // Test that overrides from outside the Blink namespace are also updated.
74 class BovineTask : public blink::Task { 86 class BovineTask : public blink::Task {
75 public: 87 public:
76 using Task::doTheWork; 88 using Task::doTheWork;
77 void reallyDoTheWork() override; 89 void reallyDoTheWork() override;
78 }; 90 };
79 91
80 class SuperBovineTask : public BovineTask { 92 class SuperBovineTask : public BovineTask {
81 public: 93 public:
82 using BovineTask::reallyDoTheWork; 94 using BovineTask::reallyDoTheWork;
83 }; 95 };
84 96
85 void BovineTask::reallyDoTheWork() { 97 void BovineTask::reallyDoTheWork() {
86 doTheWork(); 98 doTheWork();
87 // Calls via an overridden method should also be updated. 99 // Calls via an overridden method should also be updated.
88 reallyDoTheWork(); 100 reallyDoTheWork();
89 } 101 }
90 102
91 // Finally, test that method pointers are also updated. 103 // Finally, test that method pointers are also updated.
92 void F() { 104 void F() {
93 void (blink::Task::*p1)() = &blink::Task::doTheWork; 105 void (blink::Task::*p1)() = &blink::Task::doTheWork;
94 void (blink::Task::*p2)() = &BovineTask::doTheWork; 106 void (blink::Task::*p2)() = &BovineTask::doTheWork;
95 void (blink::Task::*p3)() = &blink::Task::reallyDoTheWork; 107 void (blink::Task::*p3)() = &blink::Task::reallyDoTheWork;
96 void (BovineTask::*p4)() = &BovineTask::reallyDoTheWork; 108 void (BovineTask::*p4)() = &BovineTask::reallyDoTheWork;
97 } 109 }
98 110
111 bool G() {
112 // Use the Testable class to rewrite the method.
113 blink::Testable<int> tt;
114 return tt;
115 }
116
99 namespace blink { 117 namespace blink {
100 118
101 struct StructInBlink { 119 struct StructInBlink {
102 // Structs in blink should rename their methods to capitals. 120 // Structs in blink should rename their methods to capitals.
103 bool function() { return true; } 121 bool function() { return true; }
104 }; 122 };
105 123
106 } // namespace blink 124 } // namespace blink
107 125
108 namespace WTF { 126 namespace WTF {
109 127
110 struct StructInWTF { 128 struct StructInWTF {
111 // Structs in WTF should rename their methods to capitals. 129 // Structs in WTF should rename their methods to capitals.
112 bool function() { return true; } 130 bool function() { return true; }
113 }; 131 };
114 132
115 } // namespace WTF 133 } // namespace WTF
116 134
117 void F2() { 135 void F2() {
118 blink::StructInBlink b; 136 blink::StructInBlink b;
119 b.function(); 137 b.function();
120 WTF::StructInWTF w; 138 WTF::StructInWTF w;
121 w.function(); 139 w.function();
122 } 140 }
OLDNEW
« no previous file with comments | « tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698