forked from OSchip/llvm-project
[analyzer] Updated the testcase.
Missed check added to testMallocFreeNoWarn(). Removed FIXMEs as the current behaviour is considered acceptable now. llvm-svn: 178824
This commit is contained in:
parent
80e66ce0b4
commit
06dc8aa5f8
|
@ -11,7 +11,7 @@ extern "C" void free(void *);
|
||||||
// checkers bounded with cplusplus.NewDelete.
|
// checkers bounded with cplusplus.NewDelete.
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
// malloc()/free() are subjects of unix.Malloc and unix.MallocWithAnnotations
|
//----- malloc()/free() are subjects of unix.Malloc and unix.MallocWithAnnotations
|
||||||
void testMallocFreeNoWarn() {
|
void testMallocFreeNoWarn() {
|
||||||
int i;
|
int i;
|
||||||
free(&i); // no warn
|
free(&i); // no warn
|
||||||
|
@ -24,6 +24,10 @@ void testMallocFreeNoWarn() {
|
||||||
free(p2); // no warn
|
free(p2); // no warn
|
||||||
|
|
||||||
int *p3 = (int *)malloc(sizeof(int)); // no warn
|
int *p3 = (int *)malloc(sizeof(int)); // no warn
|
||||||
|
|
||||||
|
int *p4 = (int *)malloc(sizeof(int));
|
||||||
|
free(p4);
|
||||||
|
int j = *p4; // no warn
|
||||||
}
|
}
|
||||||
|
|
||||||
void testDeleteMalloced() {
|
void testDeleteMalloced() {
|
||||||
|
@ -36,19 +40,16 @@ void testFreeOpNew() {
|
||||||
void *p = operator new(0);
|
void *p = operator new(0);
|
||||||
free(p);
|
free(p);
|
||||||
} // expected-warning{{Memory is never released; potential leak}}
|
} // expected-warning{{Memory is never released; potential leak}}
|
||||||
// FIXME: Pointer should escape
|
|
||||||
|
|
||||||
void testFreeNewExpr() {
|
void testFreeNewExpr() {
|
||||||
int *p = new int;
|
int *p = new int;
|
||||||
free(p);
|
free(p);
|
||||||
} // expected-warning{{Memory is never released; potential leak}}
|
} // expected-warning{{Memory is never released; potential leak}}
|
||||||
// FIXME: Pointer should escape
|
|
||||||
|
|
||||||
void testObjcFreeNewed() {
|
void testObjcFreeNewed() {
|
||||||
int *p = new int;
|
int *p = new int;
|
||||||
NSData *nsdata = [NSData dataWithBytesNoCopy:p length:sizeof(int) freeWhenDone:1]; // expected-warning{{Memory is never released; potential leak}}
|
NSData *nsdata = [NSData dataWithBytesNoCopy:p length:sizeof(int) freeWhenDone:1]; // expected-warning{{Memory is never released; potential leak}}
|
||||||
}
|
}
|
||||||
// FIXME: Pointer should escape
|
|
||||||
|
|
||||||
void testFreeAfterDelete() {
|
void testFreeAfterDelete() {
|
||||||
int *p = new int;
|
int *p = new int;
|
||||||
|
|
Loading…
Reference in New Issue