Hans Wennborg
d799a2b3b9
Better wording for reference self-initialization warning.
...
llvm-svn: 162198
2012-08-20 08:52:22 +00:00
Hans Wennborg
e1fdb059c6
Warn about self-initialization of references.
...
Initializing a reference with itself, e.g. "int &a = a;" seems like a
very bad idea.
llvm-svn: 162093
2012-08-17 10:12:33 +00:00
Argyrios Kyrtzidis
b4015e1877
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
llvm-svn: 155856
2012-04-30 23:23:55 +00:00
Ted Kremenek
2a14c695eb
Fix LiveVariables analysis bug with MaterializeTemporaryExpr and fix handling in ExprEngine. Fixes <rdar://problem/10201666>.
...
llvm-svn: 140956
2011-10-02 00:54:48 +00:00
Jeffrey Yasskin
0e9cdbbb06
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.
llvm-svn: 138613
2011-08-26 00:41:31 +00:00
Argyrios Kyrtzidis
e72f7154f1
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}}
}
llvm-svn: 120483
2010-11-30 22:57:32 +00:00
Argyrios Kyrtzidis
091d97c709
Revert r120331 since it causes spurious warnings and a possible assertion hit when self-host.
...
llvm-svn: 120351
2010-11-29 23:42:03 +00:00
Argyrios Kyrtzidis
569cad9734
Emit warnings if we are returning a reference to a local temporary.
...
The issue was brought to our attention by Matthieu Monrocq.
llvm-svn: 120331
2010-11-29 22:32:08 +00:00
Ted Kremenek
b786156b01
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).
...
llvm-svn: 110242
2010-08-04 20:01:07 +00:00