diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-03-30 20:31:04 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-03-30 20:31:04 +0000 |
| commit | 2d107f9d1d0bfb4b54cd5c056d2ee45c052e585e (patch) | |
| tree | 3ca3459fa3d60d196a97e98629d5244ca88c34b7 /clang/test | |
| parent | f7c226da000ae5ebbf503380422ec9ce1f70108e (diff) | |
| download | bcm5719-llvm-2d107f9d1d0bfb4b54cd5c056d2ee45c052e585e.tar.gz bcm5719-llvm-2d107f9d1d0bfb4b54cd5c056d2ee45c052e585e.zip | |
RegionStore: specially handle loads from integer global variables declared 'const'.
Fixes a false positive reported in PR 6288.
llvm-svn: 99922
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/misc-ps-region-store.m | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/test/Analysis/misc-ps-region-store.m b/clang/test/Analysis/misc-ps-region-store.m index b95d82f7633..d10b9fa5ded 100644 --- a/clang/test/Analysis/misc-ps-region-store.m +++ b/clang/test/Analysis/misc-ps-region-store.m @@ -920,3 +920,38 @@ void pr6302(id x, Class y) { // This previously crashed the analyzer (reported in PR 6302) x->isa = y; } + +//===----------------------------------------------------------------------===// +// Specially handle global variables that are declared constant. In the +// example below, this forces the loop to take exactly 2 iterations. +//===----------------------------------------------------------------------===// + +const int pr6288_L_N = 2; +void pr6288_(void) { + int x[2]; + int *px[2]; + int i; + for (i = 0; i < pr6288_L_N; i++) + px[i] = &x[i]; + *(px[0]) = 0; // no-warning +} + +void pr6288_pos(int z) { + int x[2]; + int *px[2]; + int i; + for (i = 0; i < z; i++) + px[i] = &x[i]; // expected-warning{{Access out-of-bound array element (buffer overflow)}} + *(px[0]) = 0; // expected-warning{{Dereference of undefined pointer value}} +} + +void pr6288_b(void) { + const int L_N = 2; + int x[2]; + int *px[2]; + int i; + for (i = 0; i < L_N; i++) + px[i] = &x[i]; + *(px[0]) = 0; // no-warning +} + |

