diff options
author | Anna Zaks <ganna@apple.com> | 2012-06-08 00:04:40 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-06-08 00:04:40 +0000 |
commit | 93205d0d1222d174038da32366a739c8f1fefe51 (patch) | |
tree | 146ae5d971d865bc295b986dc349982b22c3dd59 /clang/test/Analysis/malloc.c | |
parent | 1dac08da4b141848d9ee7b4b331dfb625f7d045a (diff) | |
download | bcm5719-llvm-93205d0d1222d174038da32366a739c8f1fefe51.tar.gz bcm5719-llvm-93205d0d1222d174038da32366a739c8f1fefe51.zip |
[analyze] Change some of the malloc tests to use clang_analyzer_eval.
Thanks, Jordan.
llvm-svn: 158179
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r-- | clang/test/Analysis/malloc.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index 7be29301fe6..7c2196ac9e5 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s #include "system-header-simulator.h" +void clang_analyzer_eval(int); + typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); void *valloc(size_t); @@ -861,8 +863,7 @@ int CMPRegionHeapToStack() { int x = 0; int *x1 = malloc(8); int *x2 = &x; - if (x1 == x2) - return 5/x; // expected-warning{{This statement is never executed}} + clang_analyzer_eval(x1 == x2); // expected-warning{{FALSE}} free(x1); return x; } @@ -873,8 +874,7 @@ int CMPRegionHeapToHeap2() { int *x2 = malloc(8); int *x4 = x1; int *x5 = x2; - if (x4 == x5) - return 5/x; // expected-warning{{This statement is never executed}} + clang_analyzer_eval(x4 == x5); // expected-warning{{FALSE}} free(x1); free(x2); return x; @@ -896,8 +896,7 @@ int HeapAssignment() { int *x = malloc(4); int *y = x; *x = 5; - if (*x != *y) - return 5/m; // expected-warning{{This statement is never executed}} + clang_analyzer_eval(*x != *y); // expected-warning{{FALSE}} free(x); return 0; } @@ -909,12 +908,8 @@ int cmpHeapAllocationToUnknown() { int *yBefore = retPtr(); int *m = malloc(8); int *yAfter = retPtrMightAlias(m); - if (yBefore == m) { - return 5/zero; // expected-warning {{This statement is never executed}} - } - if (yAfter == m) { - return 5/zero; // expected-warning {{This statement is never executed}} - } + clang_analyzer_eval(yBefore == m); // expected-warning{{FALSE}} + clang_analyzer_eval(yAfter == m); // expected-warning{{FALSE}} free(m); return 0; } |