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

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

Issue 2307643002: Account for the fact that some type traits have static methods. (Closed)
Patch Set: Created 4 years, 3 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 // Note: do not add any copy or move constructors to this class: doing so will 7 // Note: do not add any copy or move constructors to this class: doing so will
8 // break test coverage that we don't clobber the class name by trying to emit 8 // break test coverage that we don't clobber the class name by trying to emit
9 // replacements for synthesized functions. 9 // replacements for synthesized functions.
10 class C { 10 class C {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 class TypeTrait2 { 83 class TypeTrait2 {
84 public: 84 public:
85 static const bool value = false; 85 static const bool value = false;
86 }; 86 };
87 template <> 87 template <>
88 class TypeTrait2<void> { 88 class TypeTrait2<void> {
89 public: 89 public:
90 static const bool value = false; 90 static const bool value = false;
91 }; 91 };
92 92
93 template <typename T, typename U>
94 struct IsSubclass {
95 private:
96 typedef char YesType;
97 struct NoType {
98 char padding[8];
99 };
100
101 static YesType subclassCheck(U*);
102 static NoType subclassCheck(...);
103 static T* t;
104
105 public:
106 static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
107 };
108
109 template <typename U = void>
110 struct IsTraceableInCollection {
111 // Expanded from STATIC_ONLY(IsTraceableInCollection):
112 private:
113 IsTraceableInCollection() = delete;
114 IsTraceableInCollection(const IsTraceableInCollection&) = delete;
115 IsTraceableInCollection& operator=(const IsTraceableInCollection&) = delete;
116 void* operator new(unsigned long) = delete;
117 void* operator new(unsigned long, void*) = delete;
118
119 public:
120 static const bool value = true;
121 };
122
93 }; // namespace WTF 123 }; // namespace WTF
94 124
95 void F() { 125 void F() {
96 // Test that references to a static field are correctly rewritten. 126 // Test that references to a static field are correctly rewritten.
97 blink::C::instanceCount++; 127 blink::C::instanceCount++;
98 // Force instantiation of a copy constructor for blink::C to make sure field 128 // Force instantiation of a copy constructor for blink::C to make sure field
99 // initializers for synthesized functions don't cause weird rewrites. 129 // initializers for synthesized functions don't cause weird rewrites.
100 blink::C c; 130 blink::C c;
101 blink::C c2 = c; 131 blink::C c2 = c;
102 132
103 bool b1 = WTF::TypeTrait1::value; 133 bool b1 = WTF::TypeTrait1::value;
104 bool b2 = WTF::TypeTrait2<void>::value; 134 bool b2 = WTF::TypeTrait2<void>::value;
105 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698