[cfe-commits] r158179 - /cfe/trunk/test/Analysis/malloc.c
Anna Zaks
ganna at apple.com
Thu Jun 7 17:04:40 PDT 2012
Author: zaks
Date: Thu Jun 7 19:04:40 2012
New Revision: 158179
URL: http://llvm.org/viewvc/llvm-project?rev=158179&view=rev
Log:
[analyze] Change some of the malloc tests to use clang_analyzer_eval.
Thanks, Jordan.
Modified:
cfe/trunk/test/Analysis/malloc.c
Modified: cfe/trunk/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc.c?rev=158179&r1=158178&r2=158179&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/malloc.c (original)
+++ cfe/trunk/test/Analysis/malloc.c Thu Jun 7 19:04:40 2012
@@ -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 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 *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 *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 *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;
}
More information about the cfe-commits
mailing list