diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-11-15 19:11:43 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-11-15 19:11:43 +0000 |
commit | 63bc186d6ac0b44ba4ec6fccb5f471b05c79b666 (patch) | |
tree | 9002c9a95686003fd8a0ed2875fe5b114d4c4bde /test/Analysis/coverage.c | |
parent | f34a5791c5c9df0348714e275adb09b8cf858460 (diff) |
[analyzer] Report leaks at the closing brace of a function body.
This fixes a few cases where we'd emit path notes like this:
+---+
1| v
p = malloc(len);
^ |2
+---+
In general this should make path notes more consistent and more correct,
especially in cases where the leak happens on the false branch of an if
that jumps directly to the end of the function. There are a couple places
where the leak is reported farther away from the cause; these are usually
cases where there are several levels of nested braces before the end of
the function. This still matches our current behavior for when there /is/
a statement after all the braces, though.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168070 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/coverage.c')
-rw-r--r-- | test/Analysis/coverage.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/Analysis/coverage.c b/test/Analysis/coverage.c index 66f0a5e385..38e84e17ce 100644 --- a/test/Analysis/coverage.c +++ b/test/Analysis/coverage.c @@ -32,27 +32,27 @@ static void function_which_doesnt_give_up_nested(int *x, int *y) { void coverage1(int *x) { function_which_gives_up(x); - char *m = (char*)malloc(12); // expected-warning {{potential leak}} -} + char *m = (char*)malloc(12); +} // expected-warning {{potential leak}} void coverage2(int *x) { if (x) { function_which_gives_up(x); - char *m = (char*)malloc(12);// expected-warning {{potential leak}} + char *m = (char*)malloc(12); } -} +} // expected-warning {{potential leak}} void coverage3(int *x) { x++; function_which_gives_up(x); - char *m = (char*)malloc(12);// expected-warning {{potential leak}} -} + char *m = (char*)malloc(12); +} // expected-warning {{potential leak}} void coverage4(int *x) { *x += another_function(x); function_which_gives_up(x); - char *m = (char*)malloc(12);// expected-warning {{potential leak}} -} + char *m = (char*)malloc(12); +} // expected-warning {{potential leak}} void coverage5(int *x) { for (int i = 0; i<7; ++i) @@ -65,8 +65,8 @@ void coverage6(int *x) { for (int i = 0; i<3; ++i) { function_which_gives_up(x); } - char *m = (char*)malloc(12); // expected-warning {{potential leak}} -} + char *m = (char*)malloc(12); +} // expected-warning {{potential leak}} int coverage7_inline(int *i) { function_which_doesnt_give_up(&i); @@ -77,8 +77,8 @@ void coverage8(int *x) { int y; function_which_doesnt_give_up_nested(x, &y); y = (*x)/y; // expected-warning {{Division by zero}} - char *m = (char*)malloc(12); // expected-warning {{potential leak}} -} + char *m = (char*)malloc(12); +} // expected-warning {{potential leak}} void function_which_gives_up_settonull(int **x) { *x = 0; |