]> granicus.if.org Git - clang/commitdiff
[analyze] Change some of the malloc tests to use clang_analyzer_eval.
authorAnna Zaks <ganna@apple.com>
Fri, 8 Jun 2012 00:04:40 +0000 (00:04 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 8 Jun 2012 00:04:40 +0000 (00:04 +0000)
Thanks, Jordan.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158179 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/malloc.c

index 7be29301fe6f7f99f20bd27fe018fa32a531721b..7c2196ac9e53c28e8ab1d477aeeee508459ce154 100644 (file)
@@ -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;
 }