diff options
| author | Anna Zaks <ganna@apple.com> | 2013-03-15 01:15:12 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2013-03-15 01:15:12 +0000 |
| commit | 913b0d0078b500f80dc89725eb343b34ad849f11 (patch) | |
| tree | 06bc9ada04b11fb0b7b82cca60e8c37971d2772e /clang/test/Analysis/inlining/false-positive-suppression.c | |
| parent | 31f4354c75e22f41586896ea58845519c838c91e (diff) | |
| download | bcm5719-llvm-913b0d0078b500f80dc89725eb343b34ad849f11.tar.gz bcm5719-llvm-913b0d0078b500f80dc89725eb343b34ad849f11.zip | |
[analyzer] Teach trackNullOrUndef to look through ternary operators
Allows the suppression visitors trigger more often.
llvm-svn: 177137
Diffstat (limited to 'clang/test/Analysis/inlining/false-positive-suppression.c')
| -rw-r--r-- | clang/test/Analysis/inlining/false-positive-suppression.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/test/Analysis/inlining/false-positive-suppression.c b/clang/test/Analysis/inlining/false-positive-suppression.c index bed64f18377..fbdb1650ff4 100644 --- a/clang/test/Analysis/inlining/false-positive-suppression.c +++ b/clang/test/Analysis/inlining/false-positive-suppression.c @@ -191,3 +191,39 @@ void testAlwaysReturnNull(void *input) { #endif } +int derefArg(int *p) { + return *p; +#ifndef SUPPRESSED + // expected-warning@-2 {{Dereference of null pointer}} +#endif +} +void ternaryArg(char cond) { + static int x; + derefArg(cond ? &x : getNull()); +} + +int derefAssignment(int *p) { + return *p; +#ifndef SUPPRESSED + // expected-warning@-2 {{Dereference of null pointer}} +#endif +} +void ternaryAssignment(char cond) { + static int x; + int *p = cond ? &x : getNull(); + derefAssignment(p); +} + +int *retNull(char cond) { + static int x; + return cond ? &x : getNull(); +} +int ternaryRetNull(char cond) { + int *p = retNull(cond); + return *p; +#ifndef SUPPRESSED + // expected-warning@-2 {{Dereference of null pointer}} +#endif +} + + |

