Fix regression in modeling assignments of an address of a variable to itself. Fixes <rdar://problem/13226577>.

llvm-svn: 175852
This commit is contained in:
Ted Kremenek 2013-02-22 01:39:26 +00:00
parent 77569ffd06
commit a3bb2b6044
2 changed files with 7 additions and 3 deletions

View File

@ -471,9 +471,7 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
SVal InitVal = state->getSVal(InitEx, LC);
if (InitVal == state->getLValue(VD, LC) ||
(VD->getType()->isArrayType() &&
isa<CXXConstructExpr>(InitEx->IgnoreImplicit()))) {
if (isa<CXXConstructExpr>(InitEx->IgnoreImplicit())) {
// We constructed the object directly in the variable.
// No need to bind anything.
B.generateNode(DS, UpdatedN, state);

View File

@ -90,3 +90,9 @@ int* f5() {
int& i = i; // expected-warning {{Assigned value is garbage or undefined}} expected-note {{binding reference variable 'i' here}} expected-warning{{reference 'i' is not yet bound to a value when used within its own initialization}}
return &i; // expected-warning {{address of stack memory associated with local variable 'i' returned}}
}
void *radar13226577() {
void *p = &p;
return p; // expected-warning {{stack memory associated with local variable 'p' returned to caller}}
}