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

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

Issue 2256913002: Handling of DependentScopeDeclRefExpr and CXXDependentScopeMemberExpr nodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-style-new-clang
Patch Set: Make GuessNameForUnresolvedDependentNode and GetNameForDecl more similar. Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <type_traits>
6
5 namespace not_blink { 7 namespace not_blink {
6 8
7 void function(int x) {} 9 void function(int x) {}
8 10
9 class Class { 11 class Class {
10 public: 12 public:
11 void method() {} 13 void method() {}
14 virtual void virtualMethod() {}
12 template <typename T> 15 template <typename T>
13 void methodTemplate(T) {} 16 void methodTemplate(T) {}
14 template <typename T> 17 template <typename T>
15 static void staticMethodTemplate(T) {} 18 static void staticMethodTemplate(T) {}
16 }; 19 };
17 20
18 template <typename T> 21 template <typename T>
19 void functionTemplate(T x) {} 22 void functionTemplate(T x) {}
20 23
24 template <typename T = Class>
25 void functionTemplate2() {
26 T::staticMethodTemplate(123);
27 }
28
29 template <typename T = Class>
30 class TemplatedClass {
31 public:
32 void anotherMethod() { T::staticMethodTemplate(123); }
33 };
34
21 } // not_blink 35 } // not_blink
22 36
23 namespace blink { 37 namespace blink {
24 38
25 template <typename T, int number> 39 template <typename T, int number>
26 void F() { 40 void F() {
27 // We don't assert on this, and we don't end up considering it a const for 41 // We don't assert on this, and we don't end up considering it a const for
28 // now. 42 // now.
29 const int maybe_a_const = sizeof(T); 43 const int maybe_a_const = sizeof(T);
30 const int is_a_const = number; 44 const int is_a_const = number;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 187
174 template <typename T> 188 template <typename T>
175 void Class<T>::F(int data_size){}; 189 void Class<T>::F(int data_size){};
176 190
177 void Foo() { 191 void Foo() {
178 Class<char>().F(123); 192 Class<char>().F(123);
179 }; 193 };
180 194
181 } // namespace test_unnamed_arg 195 } // namespace test_unnamed_arg
182 196
197 namespace cxx_dependend_scope_member_expr_testing {
198
199 class PartitionAllocator {
200 public:
201 static void Method() {}
202 };
203
204 template <typename Allocator = PartitionAllocator>
205 class Vector {
206 public:
207 // https://crbug.com/582315: |Allocator::method| is a
208 // CXXDependentScopeMemberExpr.
209 void AnotherMethod() {
210 if (std::is_class<Allocator>::value) // Shouldn't rename |value|
211 Allocator::Method(); // Should rename |method| -> |Method|.
212 }
213 };
214
215 template <typename Allocator = PartitionAllocator>
216 void Test() {
217 // https://crbug.com/582315: |Allocator::method| is a
218 // DependentScopeDeclRefExpr.
219 if (std::is_class<Allocator>::value) // Shouldn't rename |value|.
220 Allocator::Method(); // Should rename |method|.
221 }
222
223 class InterceptingCanvasBase : public ::not_blink::Class {
224 public:
225 virtual void VirtualMethodInBlink(){};
226 };
227
228 template <typename DerivedCanvas>
229 class InterceptingCanvas : public InterceptingCanvasBase {
230 public:
231 void virtualMethod() override {
232 this->Class::virtualMethod(); // https://crbug.com/582315#c19
233 this->InterceptingCanvasBase::VirtualMethodInBlink();
234 }
235 };
236
237 template <typename T>
238 class ThreadSpecific {
239 public:
240 T* operator->();
241 operator T*();
242 };
243
244 template <typename T>
245 inline ThreadSpecific<T>::operator T*() {
246 return nullptr;
247 }
248
249 template <typename T>
250 inline T* ThreadSpecific<T>::operator->() {
251 return operator T*();
252 }
253
254 class Class {
255 public:
256 virtual void VirtualMethodInBlink() {}
257 };
258
259 } // namespace cxx_dependend_scope_member_expr_testing
260
183 } // namespace blink 261 } // namespace blink
262
263 namespace not_blink {
264
265 namespace cxx_dependend_scope_member_expr_testing {
dcheng 2016/12/01 07:15:06 Nit: dependent?
Łukasz Anforowicz 2016/12/01 18:26:57 Ooops. Done. :-)
266
267 class Base : public ::blink::cxx_dependend_scope_member_expr_testing::Class {
268 public:
269 virtual void virtualMethod() {}
270 };
271
272 template <typename T>
273 class Derived : public Base {
274 public:
275 void virtualMethod() override {
276 this->Class::VirtualMethodInBlink();
277 this->Base::virtualMethod();
278 }
279 };
280
281 } // namespace cxx_dependend_scope_member_expr_testing
282
283 } // namespace not_blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698