diff options
| author | Anna Zaks <ganna@apple.com> | 2012-02-02 01:30:08 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2012-02-02 01:30:08 +0000 |
| commit | 699f55b98cc4909ccec55ed766174918dd3970db (patch) | |
| tree | 3fb95705a8c2e48676afd60e2c34b19cfce0951c /clang/test/Analysis/CFContainers.mm | |
| parent | 84f6dcf2b52c2cfc8cb69e66175623a6285a43e1 (diff) | |
| download | bcm5719-llvm-699f55b98cc4909ccec55ed766174918dd3970db.tar.gz bcm5719-llvm-699f55b98cc4909ccec55ed766174918dd3970db.zip | |
[analyzer] Fix a false positive in the CFArrayCreate check that surfaces
the the code like this (due to x and &x being the same value but
different size):
void* x[] = { ptr1, ptr2, ptr3 };
CFArrayCreate(NULL, (const void **) &x, count, NULL);
llvm-svn: 149579
Diffstat (limited to 'clang/test/Analysis/CFContainers.mm')
| -rw-r--r-- | clang/test/Analysis/CFContainers.mm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/Analysis/CFContainers.mm b/clang/test/Analysis/CFContainers.mm index 5243c158178..ec6746bb728 100644 --- a/clang/test/Analysis/CFContainers.mm +++ b/clang/test/Analysis/CFContainers.mm @@ -164,3 +164,22 @@ void TestGetCount(CFArrayRef A, CFIndex sIndex, CFIndex badIndex) { const void *s1 = CFArrayGetValueAtIndex(A, sIndex); const void *s2 = CFArrayGetValueAtIndex(A, sCount);// expected-warning {{Index is out of bounds}} } + +typedef void* XX[3]; +void TestPointerToArray(int *elems, void *p1, void *p2, void *p3, unsigned count, void* fn[], char cp[]) { + void* x[] = { p1, p2, p3 }; + CFArrayCreate(0, (const void **) &x, count, 0); // no warning + + void* y[] = { p1, p2, p3 }; + CFArrayCreate(0, (const void **) y, count, 0); // no warning + XX *z = &x; + CFArrayCreate(0, (const void **) z, count, 0); // no warning + + CFArrayCreate(0, (const void **) &fn, count, 0); // false negative + CFArrayCreate(0, (const void **) fn, count, 0); // no warning + CFArrayCreate(0, (const void **) cp, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}} + + char cc[] = { 0, 2, 3 }; + CFArrayCreate(0, (const void **) &cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}} + CFArrayCreate(0, (const void **) cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}} +} |

