summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-02-11 21:02:40 +0000
committerAnna Zaks <ganna@apple.com>2012-02-11 21:02:40 +0000
commitd3571e5ad3cc43dd2f2d968c9bdddaa393887b63 (patch)
tree069c4fb4353d0f2a9713b5fdb9da042675205995 /clang/test
parentbb1ef9011db49968679615ba6c8811b0ac61232d (diff)
downloadbcm5719-llvm-d3571e5ad3cc43dd2f2d968c9bdddaa393887b63.tar.gz
bcm5719-llvm-d3571e5ad3cc43dd2f2d968c9bdddaa393887b63.zip
[analyzer] Malloc checker: Leak bugs should be suppressed by sinks.
Resolves a common false positive, where we were reporting a leak inside asserts llvm-svn: 150312
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/malloc.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c
index a219e92787a..89299e6637d 100644
--- a/clang/test/Analysis/malloc.c
+++ b/clang/test/Analysis/malloc.c
@@ -340,21 +340,15 @@ int **RegInvalidationDetect2(int **pp) {
return 0;// expected-warning {{Allocated memory never released. Potential memory leak.}}
}
-// Below are the known false positives.
-
extern void exit(int) __attribute__ ((__noreturn__));
void mallocExit(int *g) {
struct xx *p = malloc(12);
-
- if (g != 0) {
- exit(1); // expected-warning{{Allocated memory never released. Potential memory leak}}
- }
+ if (g != 0)
+ exit(1);
free(p);
return;
}
-
-// TODO: There should be no warning here.
extern void __assert_fail (__const char *__assertion, __const char *__file,
unsigned int __line, __const char *__function)
__attribute__ ((__noreturn__));
@@ -363,11 +357,13 @@ extern void __assert_fail (__const char *__assertion, __const char *__file,
void mallocAssert(int *g) {
struct xx *p = malloc(12);
- assert(g != 0); // expected-warning{{Allocated memory never released. Potential memory leak}}
+ assert(g != 0);
free(p);
return;
}
+// Below are the known false positives.
+
// TODO: There should be no warning here.
void reallocFails(int *g, int f) {
char *p = malloc(12);
OpenPOWER on IntegriCloud