@@ -7,6 +7,9 @@ void WTFBreakpointTrap();
7
7
void WTFCrashWithInfo (int , const char *, const char *, int );
8
8
void WTFReportAssertionFailure (const char * file, int line, const char * function, const char * assertion);
9
9
10
+ void WTFCrash (void );
11
+ void WTFCrashWithSecurityImplication (void );
12
+
10
13
inline void compilerFenceForCrash ()
11
14
{
12
15
asm volatile (" " ::: " memory" );
@@ -62,14 +65,25 @@ void WTFCrashWithInfo(int line, const char* file, const char* function, int coun
62
65
template <typename ToType, typename FromType>
63
66
ToType bitwise_cast (FromType from);
64
67
68
+ namespace std {
69
+
65
70
template <typename T>
66
71
T* addressof (T& arg);
67
72
73
+ template <typename T>
74
+ T&& forward(T& arg);
75
+
76
+ template <typename T>
77
+ T&& move( T&& t );
78
+
79
+ } // namespace std
80
+
68
81
bool isMainThread ();
69
82
bool isMainThreadOrGCThread ();
70
83
bool isMainRunLoop ();
71
84
bool isWebThread ();
72
85
bool isUIThread ();
86
+ bool mayBeGCThread ();
73
87
74
88
enum class Flags : unsigned short {
75
89
Flag1 = 1 << 0 ,
@@ -161,16 +175,42 @@ class Number {
161
175
162
176
class ComplexNumber {
163
177
public:
164
- ComplexNumber () : real (0 ), complex (0 ) { }
178
+ ComplexNumber () : realPart (0 ), complexPart (0 ) { }
165
179
ComplexNumber (const ComplexNumber&);
166
- ComplexNumber& operator ++() { real .someMethod (); return *this ; }
180
+ ComplexNumber& operator ++() { realPart .someMethod (); return *this ; }
167
181
ComplexNumber operator ++(int );
168
182
ComplexNumber& operator <<(int );
169
183
ComplexNumber& operator +();
170
184
185
+ const Number& real () const { return realPart; }
186
+
171
187
private:
172
- Number real;
173
- Number complex;
188
+ Number realPart;
189
+ Number complexPart;
190
+ };
191
+
192
+ class ObjectWithNonTrivialDestructor {
193
+ public:
194
+ ObjectWithNonTrivialDestructor () { }
195
+ ObjectWithNonTrivialDestructor (unsigned v) : v(v) { }
196
+ ~ObjectWithNonTrivialDestructor () { }
197
+
198
+ unsigned value () const { return v; }
199
+
200
+ private:
201
+ unsigned v { 0 };
202
+ };
203
+
204
+ class ObjectWithMutatingDestructor {
205
+ public:
206
+ ObjectWithMutatingDestructor () : n(0 ) { }
207
+ ObjectWithMutatingDestructor (int n) : n(n) { }
208
+ ~ObjectWithMutatingDestructor () { n.someMethod (); }
209
+
210
+ unsigned value () const { return n.value (); }
211
+
212
+ private:
213
+ Number n;
174
214
};
175
215
176
216
class RefCounted {
@@ -248,14 +288,29 @@ class RefCounted {
248
288
int trivial40 () { return v << 2 ; }
249
289
unsigned trivial41 () { v = ++s_v; return v; }
250
290
unsigned trivial42 () { return bitwise_cast<unsigned long >(nullptr ); }
251
- Number* trivial43 () { return addressof (*number); }
291
+ Number* trivial43 () { return std:: addressof (*number); }
252
292
Number* trivial44 () { return new Number (1 ); }
253
293
ComplexNumber* trivial45 () { return new ComplexNumber (); }
254
294
void trivial46 () { ASSERT (isMainThread ()); }
255
295
void trivial47 () { ASSERT (isMainThreadOrGCThread ()); }
256
296
void trivial48 () { ASSERT (isMainRunLoop ()); }
257
297
void trivial49 () { ASSERT (isWebThread ()); }
258
298
void trivial50 () { ASSERT (isUIThread ()); }
299
+ void trivial51 () { ASSERT (mayBeGCThread ()); }
300
+ void trivial52 () { WTFCrash (); }
301
+ void trivial53 () { WTFCrashWithSecurityImplication (); }
302
+ unsigned trivial54 () { return ComplexNumber ().real ().value (); }
303
+ Number&& trivial55() { return std::forward (*number); }
304
+ unsigned trivial56 () { Number n { 5 }; return std::move (n).value (); }
305
+ void trivial57 () { do { break ; } while (1 ); }
306
+ void trivial58 () { do { continue ; } while (0 ); }
307
+ void trivial59 () {
308
+ do { goto label; }
309
+ while (0 );
310
+ label:
311
+ return ;
312
+ }
313
+ unsigned trivial60 () { return ObjectWithNonTrivialDestructor { 5 }.value (); }
259
314
260
315
static RefCounted& singleton () {
261
316
static RefCounted s_RefCounted;
@@ -335,6 +390,7 @@ class RefCounted {
335
390
ComplexNumber nonTrivial17 () { return complex << 2 ; }
336
391
ComplexNumber nonTrivial18 () { return +complex; }
337
392
ComplexNumber* nonTrivial19 () { return new ComplexNumber (complex); }
393
+ unsigned nonTrivial20 () { return ObjectWithMutatingDestructor { 7 }.value (); }
338
394
339
395
static unsigned s_v;
340
396
unsigned v { 0 };
@@ -413,6 +469,16 @@ class UnrelatedClass {
413
469
getFieldTrivial ().trivial48 (); // no-warning
414
470
getFieldTrivial ().trivial49 (); // no-warning
415
471
getFieldTrivial ().trivial50 (); // no-warning
472
+ getFieldTrivial ().trivial51 (); // no-warning
473
+ getFieldTrivial ().trivial52 (); // no-warning
474
+ getFieldTrivial ().trivial53 (); // no-warning
475
+ getFieldTrivial ().trivial54 (); // no-warning
476
+ getFieldTrivial ().trivial55 (); // no-warning
477
+ getFieldTrivial ().trivial56 (); // no-warning
478
+ getFieldTrivial ().trivial57 (); // no-warning
479
+ getFieldTrivial ().trivial58 (); // no-warning
480
+ getFieldTrivial ().trivial59 (); // no-warning
481
+ getFieldTrivial ().trivial60 (); // no-warning
416
482
417
483
RefCounted::singleton ().trivial18 (); // no-warning
418
484
RefCounted::singleton ().someFunction (); // no-warning
@@ -457,6 +523,8 @@ class UnrelatedClass {
457
523
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
458
524
getFieldTrivial ().nonTrivial19 ();
459
525
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
526
+ getFieldTrivial ().nonTrivial20 ();
527
+ // expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
460
528
}
461
529
};
462
530
0 commit comments