diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-09-13 18:18:37 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-09-13 18:18:37 +0000 |
commit | be879727893994532b4a643bfae6fb656742057f (patch) | |
tree | 8301686948a8bad7dc549b98878a0461d4756c6d /test/Analysis/unix-fns.c | |
parent | ca5c4c9bfeb4b1ac645b04723c0319b0fc96073e (diff) |
When warning about unsafe uses of dispatch_once, specially handle the
crazy case where dispatch_once gets redefined as a macro that calls
_dispatch_once (which calls the real dispatch_once). Users want to
see the warning in their own code.
Fixes <rdar://problem/11617767>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163816 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/unix-fns.c')
-rw-r--r-- | test/Analysis/unix-fns.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Analysis/unix-fns.c b/test/Analysis/unix-fns.c index ec620985d9..f9c052e165 100644 --- a/test/Analysis/unix-fns.c +++ b/test/Analysis/unix-fns.c @@ -136,3 +136,18 @@ void test_valloc_nowarn(size_t sz) { foo[i] = 0; } } + +// Test dispatch_once being a macro that wraps a call to _dispatch_once, which in turn +// calls the real dispatch_once. + +static inline void _dispatch_once(dispatch_once_t *predicate, dispatch_block_t block) +{ + dispatch_once(predicate, block); +} + +#define dispatch_once _dispatch_once + +void test_dispatch_once_in_macro() { + dispatch_once_t pred = 0; + dispatch_once(&pred, ^(){}); // expected-warning {{Call to 'dispatch_once' uses the local variable 'pred' for the predicate value}} +} |