30 lines · c
1// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,debug.ExprInspection \2// RUN: -analyzer-output=text -verify %s3 4extern void clang_analyzer_eval(int);5 6int OSAtomicCompareAndSwapPtrBarrier(void *, void *, void **);7int OSAtomicCompareAndSwapPtrBarrier(void *, void *, void **) {8 // There is some body in the actual header,9 // but we should trust our BodyFarm instead.10}11 12int *invalidSLocOnRedecl(void) {13 // Was crashing when trying to throw a report about returning an uninitialized14 // value to the caller. FIXME: We should probably still throw that report,15 // something like "The "compare" part of CompareAndSwap depends on an16 // undefined value".17 int *b;18 OSAtomicCompareAndSwapPtrBarrier(0, 0, (void**)&b); // no-crash19 return b;20}21 22void testThatItActuallyWorks(void) {23 void *x = 0;24 int res = OSAtomicCompareAndSwapPtrBarrier(0, &x, &x);25 clang_analyzer_eval(res); // expected-warning{{TRUE}}26 // expected-note@-1{{TRUE}}27 clang_analyzer_eval(x == &x); // expected-warning{{TRUE}}28 // expected-note@-1{{TRUE}}29}30