@@ -59,6 +59,18 @@ void WTFCrashWithInfo(int line, const char* file, const char* function, int coun
59
59
WTFCrashWithInfoImpl (line, file, function, counter, wtfCrashArg (reason));
60
60
}
61
61
62
+ template <typename ToType, typename FromType>
63
+ ToType bitwise_cast (FromType from);
64
+
65
+ template <typename T>
66
+ T* addressof (T& arg);
67
+
68
+ bool isMainThread ();
69
+ bool isMainThreadOrGCThread ();
70
+ bool isMainRunLoop ();
71
+ bool isWebThread ();
72
+ bool isUIThread ();
73
+
62
74
enum class Flags : unsigned short {
63
75
Flag1 = 1 << 0 ,
64
76
Flag2 = 1 << 1 ,
@@ -234,6 +246,16 @@ class RefCounted {
234
246
void trivial38 () { v++; if (__builtin_expect (!!(number), 1 )) (*number)++; }
235
247
int trivial39 () { return -v; }
236
248
int trivial40 () { return v << 2 ; }
249
+ unsigned trivial41 () { v = ++s_v; return v; }
250
+ unsigned trivial42 () { return bitwise_cast<unsigned long >(nullptr ); }
251
+ Number* trivial43 () { return addressof (*number); }
252
+ Number* trivial44 () { return new Number (1 ); }
253
+ ComplexNumber* trivial45 () { return new ComplexNumber (); }
254
+ void trivial46 () { ASSERT (isMainThread ()); }
255
+ void trivial47 () { ASSERT (isMainThreadOrGCThread ()); }
256
+ void trivial48 () { ASSERT (isMainRunLoop ()); }
257
+ void trivial49 () { ASSERT (isWebThread ()); }
258
+ void trivial50 () { ASSERT (isUIThread ()); }
237
259
238
260
static RefCounted& singleton () {
239
261
static RefCounted s_RefCounted;
@@ -312,13 +334,17 @@ class RefCounted {
312
334
void nonTrivial16 () { complex++; }
313
335
ComplexNumber nonTrivial17 () { return complex << 2 ; }
314
336
ComplexNumber nonTrivial18 () { return +complex; }
337
+ ComplexNumber* nonTrivial19 () { return new ComplexNumber (complex); }
315
338
339
+ static unsigned s_v;
316
340
unsigned v { 0 };
317
341
Number* number { nullptr };
318
342
ComplexNumber complex;
319
343
Enum enumValue { Enum::Value1 };
320
344
};
321
345
346
+ unsigned RefCounted::s_v = 0 ;
347
+
322
348
RefCounted* refCountedObj ();
323
349
324
350
void test ()
@@ -377,6 +403,16 @@ class UnrelatedClass {
377
403
getFieldTrivial ().trivial38 (); // no-warning
378
404
getFieldTrivial ().trivial39 (); // no-warning
379
405
getFieldTrivial ().trivial40 (); // no-warning
406
+ getFieldTrivial ().trivial41 (); // no-warning
407
+ getFieldTrivial ().trivial42 (); // no-warning
408
+ getFieldTrivial ().trivial43 (); // no-warning
409
+ getFieldTrivial ().trivial44 (); // no-warning
410
+ getFieldTrivial ().trivial45 (); // no-warning
411
+ getFieldTrivial ().trivial46 (); // no-warning
412
+ getFieldTrivial ().trivial47 (); // no-warning
413
+ getFieldTrivial ().trivial48 (); // no-warning
414
+ getFieldTrivial ().trivial49 (); // no-warning
415
+ getFieldTrivial ().trivial50 (); // no-warning
380
416
381
417
RefCounted::singleton ().trivial18 (); // no-warning
382
418
RefCounted::singleton ().someFunction (); // no-warning
@@ -419,6 +455,8 @@ class UnrelatedClass {
419
455
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
420
456
getFieldTrivial ().nonTrivial18 ();
421
457
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
458
+ getFieldTrivial ().nonTrivial19 ();
459
+ // expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
422
460
}
423
461
};
424
462
0 commit comments