[analyzer] MallocChecker Cleanup - harden against crashes, fix an error
(use of return instead of continue), wording.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150215 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/malloc-annotations.c b/test/Analysis/malloc-annotations.c
index 0d7e402..7890cfc 100644
--- a/test/Analysis/malloc-annotations.c
+++ b/test/Analysis/malloc-annotations.c
@@ -199,13 +199,13 @@
void f7() {
char *x = (char*) malloc(4);
free(x);
- x[0] = 'a'; // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ x[0] = 'a'; // expected-warning{{Use of dynamically allocated memory after it is freed.}}
}
void f7_realloc() {
char *x = (char*) malloc(4);
realloc(x,0);
- x[0] = 'a'; // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ x[0] = 'a'; // expected-warning{{Use of dynamically allocated memory after it is freed.}}
}
void PR6123() {
diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c
index 7ffc9a1..8d62956 100644
--- a/test/Analysis/malloc.c
+++ b/test/Analysis/malloc.c
@@ -84,13 +84,13 @@
void f7() {
char *x = (char*) malloc(4);
free(x);
- x[0] = 'a'; // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ x[0] = 'a'; // expected-warning{{Use of dynamically allocated memory after it is freed.}}
}
void f7_realloc() {
char *x = (char*) malloc(4);
realloc(x,0);
- x[0] = 'a'; // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ x[0] = 'a'; // expected-warning{{Use of dynamically allocated memory after it is freed.}}
}
void PR6123() {
@@ -186,7 +186,7 @@
int *p = malloc(12);
myfoo(p);
free(p);
- myfoo(p); // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ myfoo(p); // expected-warning{{Use of dynamically allocated memory after it is freed.}}
}
int *myalloc();
@@ -212,7 +212,7 @@
int *x = malloc(12);
int *y = x;
free(y);
- myfoo(x); // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ myfoo(x); // expected-warning{{Use of dynamically allocated memory after it is freed.}}
}
void mallocEscapeMalloc() {
@@ -236,8 +236,8 @@
void mallocFreeUse_params() {
int *p = malloc(12);
free(p);
- myfoo(p); //expected-warning{{Use dynamically allocated memory after it is freed}}
- myfooint(*p); //expected-warning{{Use dynamically allocated memory after it is freed}}
+ myfoo(p); //expected-warning{{Use of dynamically allocated memory after it is freed}}
+ myfooint(*p); //expected-warning{{Use of dynamically allocated memory after it is freed}}
}
void mallocFailedOrNot() {
@@ -248,6 +248,18 @@
free(p);
}
+struct StructWithInt {
+ int g;
+};
+void nonSymbolAsFirstArg(int *pp, struct StructWithInt *p);
+
+void mallocEscapeFooNonSymbolArg() {
+ struct StructWithInt *p = malloc(sizeof(struct StructWithInt));
+ nonSymbolAsFirstArg(&p->g, p);
+ return; // no warning
+}
+
+
int *Gl;
struct GlStTy {
int *x;