diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-06-08 10:00:00 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-06-08 10:00:00 +0000 |
commit | 1622a547971cee50e386b4cdfe62ed1fcee1036d (patch) | |
tree | d5e849b80aa730e98b0d4a91ae95429b3aa4d2a2 /test/Analysis | |
parent | 30d91718a676177f0d0d0210ce4fdb4f616df6e5 (diff) |
Add a checker check if a global variable holds a local variable's address after
the function call is left where the local variable is declared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105602 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/stackaddrleak.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Analysis/stackaddrleak.c b/test/Analysis/stackaddrleak.c new file mode 100644 index 0000000000..0076b27a3c --- /dev/null +++ b/test/Analysis/stackaddrleak.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -analyzer-experimental-internal-checks -verify %s + +char const *p; + +void f0() { + char const str[] = "This will change"; + p = str; // expected-warning {{Stack address was saved into a global variable.}} +} + +void f1() { + char const str[] = "This will change"; + p = str; + p = 0; // no-warning +} |