diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-04-11 22:22:05 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-04-11 22:22:05 +0000 |
commit | 9fec9b1fbd32e71ce8acb701165fd6649b3d8285 (patch) | |
tree | be0f7b849e2ee77a96d710daa3a6046163e6c7b2 /test | |
parent | d762357055f3d82959604743dbff20ca337e04be (diff) | |
download | clang-9fec9b1fbd32e71ce8acb701165fd6649b3d8285.tar.gz |
C++ static analysis: also invalidate fields of objects that are the callees in C++ method calls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Analysis/misc-ps-region-store.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index 2b79bdbd82..94bfc278b5 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/test/Analysis/misc-ps-region-store.cpp @@ -303,3 +303,36 @@ void PR9645() { PR9645_SideEffect::PR9645_SideEffect(int *pi) : i_(pi) {} void PR9645_SideEffect::Read(int *pi) { *i_ = *pi; } + +// Invalidate fields during C++ method calls. +class RDar9267815 { + int x; + void test(); + void test_pos(); + void test2(); + void invalidate(); +}; + +void RDar9267815::test_pos() { + int *p = 0; + if (x == 42) + return; + *p = 0xDEADBEEF; // expected-warning {{null}} +} +void RDar9267815::test() { + int *p = 0; + if (x == 42) + return; + if (x == 42) + *p = 0xDEADBEEF; // no-warning +} + +void RDar9267815::test2() { + int *p = 0; + if (x == 42) + return; + invalidate(); + if (x == 42) + *p = 0xDEADBEEF; // expected-warning {{null}} +} + |