diff options
author | Anna Zaks <ganna@apple.com> | 2012-02-10 01:11:00 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-02-10 01:11:00 +0000 |
commit | 3188686c55bc5841b7403fe147f841b5d3736ad4 (patch) | |
tree | e35f5b1691ae41e4b76445edaec2c153743b557a /clang/test/Analysis/malloc.c | |
parent | baa41d41758beb136975047ce14c5f148fc050ba (diff) | |
download | bcm5719-llvm-3188686c55bc5841b7403fe147f841b5d3736ad4.tar.gz bcm5719-llvm-3188686c55bc5841b7403fe147f841b5d3736ad4.zip |
[analyzer] MallocChecker Cleanup - harden against crashes, fix an error
(use of return instead of continue), wording.
llvm-svn: 150215
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r-- | clang/test/Analysis/malloc.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index 7ffc9a1ec00..8d6295609b9 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -84,13 +84,13 @@ void pr6293() { 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 @@ void mallocEscapeFreeUse() { 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 @@ void mallocBindFreeUse() { 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 mallocFreeMalloc() { 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 @@ void mallocFailedOrNot() { 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; |