diff options
| author | Ted Kremenek <kremenek@apple.com> | 2009-05-08 00:32:39 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2009-05-08 00:32:39 +0000 |
| commit | 3975f17f0424099aeef188dce46f19cb74cd8493 (patch) | |
| tree | 7d2804e01847c60d7d1f4a3bf1fc967a4e9e2b03 /clang/test | |
| parent | 36b9026fa71334dbc71cbaecd96990e21488c009 (diff) | |
| download | bcm5719-llvm-3975f17f0424099aeef188dce46f19cb74cd8493.tar.gz bcm5719-llvm-3975f17f0424099aeef188dce46f19cb74cd8493.zip | |
Fix <rdar://problem/6845148>. Signed integers compared against pointers should
implicitly be changed to unsigned values in GRSimpleVals.cpp. This can happen
when the comparison involves logic in specialized transfer functions (e.g.,
OSAtomicCompareAndSwap).
llvm-svn: 71200
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/misc-ps-64.m | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/test/Analysis/misc-ps-64.m b/clang/test/Analysis/misc-ps-64.m index c95998fd36f..163da4b4abe 100644 --- a/clang/test/Analysis/misc-ps-64.m +++ b/clang/test/Analysis/misc-ps-64.m @@ -6,6 +6,7 @@ // <rdar://problem/6440393> - A bunch of misc. failures involving evaluating // these expressions and building CFGs. These tests are here to prevent // regressions. +typedef long long int64_t; @class NSString, NSDictionary; typedef long NSInteger; typedef unsigned long NSUInteger; @@ -23,3 +24,26 @@ void rdar_6440393_1(NSDictionary *dict) { shazam(x, &bufptr); } +// <rdar://problem/6845148> - In this example we got a signedness +// mismatch between the literal '0' and the value of 'scrooge'. The +// trick is to have the evaluator convert the literal to an unsigned +// integer when doing a comparison with the pointer. This happens +// because of the transfer function logic of +// OSAtomicCompareAndSwap64Barrier, which doesn't have special casts +// in place to do this for us. +_Bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue ); +extern id objc_lookUpClass(const char *name); +void rdar_6845148(id debug_yourself) { + if (!debug_yourself) { + const char *wacky = ((void *)0); + Class scrooge = wacky ? (Class)objc_lookUpClass(wacky) : ((void *)0); + OSAtomicCompareAndSwap64Barrier(0, (int64_t)scrooge, (int64_t*)&debug_yourself); + } +} +void rdar_6845148_b(id debug_yourself) { + if (!debug_yourself) { + const char *wacky = ((void *)0); + Class scrooge = wacky ? (Class)objc_lookUpClass(wacky) : ((void *)0); + OSAtomicCompareAndSwap64Barrier((int64_t)scrooge, 0, (int64_t*)&debug_yourself); + } +} |

