History log of /external/clang/test/Analysis/stack-addr-ps.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
76b5dd48c9dbf2ed3e5830060ea55b81b7d1cca0 26-Jul-2013 Pavel Labath <labath@google.com> [analyzer] Fix FP warnings when binding a temporary to a local static variable

Summary:
When binding a temporary object to a static local variable, the analyzer would
complain about a dangling reference even though the temporary's lifetime should
be extended past the end of the function. This commit tries to detect these
cases and construct them in a global memory region instead of a local one.

Reviewers: jordan_rose

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1133

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187196 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
112344ab7f96cf482bce80530676712c282756d5 01-May-2013 Jordan Rose <jordan_rose@apple.com> Re-apply "[analyzer] Model casts to bool differently from other numbers."

This doesn't appear to be the cause of the slowdown. I'll have to try a
manual bisect to see if there's really anything there, or if it's just
the bot itself taking on additional load. Meanwhile, this change helps
with correctness.

This changes an assertion and adds a test case, then re-applies r180638,
which was reverted in r180714.

<rdar://problem/13296133> and PR15863

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180864 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
7e6b564d59df6c0594bc3a577f33536850290dec 29-Apr-2013 Jordan Rose <jordan_rose@apple.com> Revert "[analyzer] Model casts to bool differently from other numbers."

This seems to be causing quite a slowdown on our internal analyzer bot,
and I'm not sure why. Needs further investigation.

This reverts r180638 / 9e161ea981f22ae017b6af09d660bfc3ddf16a09.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180714 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
5e6c06bc7deaaefe130b730032a9acb9cd38bf0c 26-Apr-2013 Jordan Rose <jordan_rose@apple.com> [analyzer] Model casts to bool differently from other numbers.

Casts to bool (and _Bool) are equivalent to checks against zero,
not truncations to 1 bit or 8 bits.

This improved reasoning does cause a change in the behavior of the alpha
BoolAssignment checker. Previously, this checker complained about statements
like "bool x = y" if 'y' was known not to be 0 or 1. Now it does not, since
that conversion is well-defined. It's hard to say what the "best" behavior
here is: this conversion is safe, but might be better written as an explicit
comparison against zero.

More usefully, besides improving our model of booleans, this fixes spurious
warnings when returning the address of a local variable cast to bool.

<rdar://problem/13296133>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180638 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
5e5440ba9c135f523f72e7e7c5da59d390d697c5 22-Feb-2013 Jordan Rose <jordan_rose@apple.com> [analyzer] Make sure a materialized temporary matches its bindings.

This is a follow-up to r175830, which made sure a temporary object region
created for, say, a struct rvalue matched up with the initial bindings
being stored into it. This does the same for the case in which the AST
actually tells us that we need to create a temporary via a
MaterializeObjectExpr. I've unified the two code paths and moved a static
helper function onto ExprEngine.

This also caused a bit of test churn, causing us to go back to describing
temporary regions without a 'const' qualifier. This seems acceptable; it's
our behavior from a few months ago.

<rdar://problem/13265460> (part 2)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175854 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
f08740ba5903d089a53cc315c19286e2189f9ff3 22-Feb-2013 Ted Kremenek <kremenek@apple.com> Fix regression in modeling assignments of an address of a variable to itself. Fixes <rdar://problem/13226577>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175852 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
5965b7c7ddf8d9635426943a05441c71cb59fef6 20-Aug-2012 Hans Wennborg <hans@hanshq.net> Better wording for reference self-initialization warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162198 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
8be9e77f7e532866fa0ef2bc8c3cd549f0cc8da2 17-Aug-2012 Hans Wennborg <hans@hanshq.net> Warn about self-initialization of references.

Initializing a reference with itself, e.g. "int &a = a;" seems like a
very bad idea.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162093 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
e720ce7a3b1c1bfa5f7482183caa6e31fca9a3fb 01-May-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> When going through references to check if the function returns the address
of a local variable, make sure we don't infinitely recurse when the
reference binds to itself.

e.g:

int* func() {
int& i = i; // assign non-exist variable to a reference which has same name.
return &i; // return pointer
}

rdar://11345441

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155856 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
6a835dddf45922e71a87637fdfac0863de65123c 02-Oct-2011 Ted Kremenek <kremenek@apple.com> Fix LiveVariables analysis bug with MaterializeTemporaryExpr and fix handling in ExprEngine. Fixes <rdar://problem/10201666>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140956 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
782f63ecd124f9384f988dc7e0cf4ae1540c15f6 26-Aug-2011 Jeffrey Yasskin <jyasskin@google.com> Handle CXXTempObjectRegion in StackAddrEscapeChecker.

Also convert stack-addr-ps.cpp to use the analyzer instead of just Sema, now
that it doesn't crash, and extract the stack-block test into another file since
it errors, and that prevents the analyzer from running.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138613 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
26e10bea3d2e9d2979194890e51b98ecea165a96 30-Nov-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Follow through references to catch returned stack addresses, local blocks, label addresses or references to temporaries, e.g:

const int& g2() {
int s1;
int &s2 = s1; // expected-note {{binding reference variable 's2' here}}
return s2; // expected-warning {{reference to stack memory associated with local variable 's1' returned}}
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120483 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
d976ca4fcacdd965446bcfbe8cb03b4ee67cd827 30-Nov-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Revert r120331 since it causes spurious warnings and a possible assertion hit when self-host.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120351 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
8b2f01b56209f4bb7331292225c5300753880044 29-Nov-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Emit warnings if we are returning a reference to a local temporary.
The issue was brought to our attention by Matthieu Monrocq.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120331 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp
68957a919084ab8bbd1f01d534db1d6f31d0f459 04-Aug-2010 Ted Kremenek <kremenek@apple.com> Teach SemaChecking::CheckReturnStackAddr about ImplicitCastExprs that convert values to an lvalue. This allows us to warn (again) about returning references to stack variables. (fixes PR 7812).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110242 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Analysis/stack-addr-ps.cpp