From: Anna Zaks Date: Fri, 8 Jun 2012 00:04:40 +0000 (+0000) Subject: [analyze] Change some of the malloc tests to use clang_analyzer_eval. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=adccc3f088784423ec8048b00dc2e76140e0c3f1;p=clang [analyze] Change some of the malloc tests to use clang_analyzer_eval. Thanks, Jordan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158179 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index 7be29301fe..7c2196ac9e 100644 --- a/test/Analysis/malloc.c +++ b/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; }