diff options
| author | Jordan Rose <jordan_rose@apple.com> | 2013-05-03 05:47:31 +0000 |
|---|---|---|
| committer | Jordan Rose <jordan_rose@apple.com> | 2013-05-03 05:47:31 +0000 |
| commit | 320fbf057c7bcdfd45b90747a9acf93cde93ec38 (patch) | |
| tree | 9e5b98b69c73b4aa4af0bedbd6226d8527d39b9e /clang/test | |
| parent | cea47b78fcaa21c076ff16c00e74a33ba827b72a (diff) | |
| download | bcm5719-llvm-320fbf057c7bcdfd45b90747a9acf93cde93ec38.tar.gz bcm5719-llvm-320fbf057c7bcdfd45b90747a9acf93cde93ec38.zip | |
[analyzer] Check the stack frame when looking for a var's initialization.
FindLastStoreBRVisitor is responsible for finding where a particular region
gets its value; if the region is a VarRegion, it's possible that value was
assigned at initialization, i.e. at its DeclStmt. However, if a function is
called recursively, the same DeclStmt may be evaluated multiple times in
multiple stack frames. FindLastStoreBRVisitor was not taking this into
account and just picking the first one it saw.
<rdar://problem/13787723>
llvm-svn: 180997
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/inlining/false-positive-suppression.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/Analysis/inlining/false-positive-suppression.c b/clang/test/Analysis/inlining/false-positive-suppression.c index a836d9c6243..c5c6bb875ea 100644 --- a/clang/test/Analysis/inlining/false-positive-suppression.c +++ b/clang/test/Analysis/inlining/false-positive-suppression.c @@ -143,6 +143,27 @@ void testTrackNullVariable() { #endif } +void inlinedIsDifferent(int inlined) { + int i; + + // We were erroneously picking up the inner stack frame's initialization, + // even though the error occurs in the outer stack frame! + int *p = inlined ? &i : getNull(); + + if (!inlined) + inlinedIsDifferent(1); + + *p = 1; +#ifndef SUPPRESSED + // expected-warning@-2 {{Dereference of null pointer}} +#endif +} + +void testInlinedIsDifferent() { + // <rdar://problem/13787723> + inlinedIsDifferent(0); +} + // --------------------------------------- // FALSE NEGATIVES (over-suppression) |

