-// 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);
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;
}
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;
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;
}
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;
}