summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/simple-stream-checks.c
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-11-03 02:54:20 +0000
committerAnna Zaks <ganna@apple.com>2012-11-03 02:54:20 +0000
commit8d1f6ed9a862a516e50f40b88bae09205316b10a (patch)
treec0bc60ddfec48a3aa69429a0796cdce7267e3955 /clang/test/Analysis/simple-stream-checks.c
parent44dc91b4df5d6e0264e9fd799ac8b473b25d0f32 (diff)
downloadbcm5719-llvm-8d1f6ed9a862a516e50f40b88bae09205316b10a.tar.gz
bcm5719-llvm-8d1f6ed9a862a516e50f40b88bae09205316b10a.zip
[analyzer] Run remove dead on end of path.
This will simplify checkers that need to register for leaks. Currently, they have to register for both: check dead and check end of path. I've modified the SymbolReaper to consider everything on the stack dead if the input StackLocationContext is 0. (This is a bit disruptive, so I'd like to flash out all the issues asap.) llvm-svn: 167352
Diffstat (limited to 'clang/test/Analysis/simple-stream-checks.c')
-rw-r--r--clang/test/Analysis/simple-stream-checks.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/Analysis/simple-stream-checks.c b/clang/test/Analysis/simple-stream-checks.c
index fca2edc28ed..7a2718ebc5a 100644
--- a/clang/test/Analysis/simple-stream-checks.c
+++ b/clang/test/Analysis/simple-stream-checks.c
@@ -49,3 +49,17 @@ void CloseOnlyOnValidFileHandle() {
fclose(F);
int x = 0; // no warning
}
+
+void leakOnEnfOfPath1(int *Data) {
+ FILE *F = fopen("myfile.txt", "w");// expected-warning {{Opened file is never closed; potential resource leak}}
+}
+
+void leakOnEnfOfPath2(int *Data) {
+ FILE *F = fopen("myfile.txt", "w");
+ return; // expected-warning {{Opened file is never closed; potential resource leak}}
+}
+
+FILE *leakOnEnfOfPath3(int *Data) {
+ FILE *F = fopen("myfile.txt", "w");
+ return F;
+}
OpenPOWER on IntegriCloud