forked from OSchip/llvm-project
Fix LiveVariables analysis bug with MaterializeTemporaryExpr and fix handling in ExprEngine. Fixes <rdar://problem/10201666>.
llvm-svn: 140956
This commit is contained in:
parent
d07a59f288
commit
2a14c695eb
|
@ -372,10 +372,6 @@ void TransferFunctions::Visit(Stmt *S) {
|
|||
S = cast<CXXBindTemporaryExpr>(S)->getSubExpr();
|
||||
break;
|
||||
}
|
||||
case Stmt::MaterializeTemporaryExprClass: {
|
||||
S = cast<MaterializeTemporaryExpr>(S)->GetTemporaryExpr();
|
||||
break;
|
||||
}
|
||||
case Stmt::UnaryExprOrTypeTraitExprClass: {
|
||||
// No need to unconditionally visit subexpressions.
|
||||
return;
|
||||
|
|
|
@ -107,22 +107,19 @@ const CXXThisRegion *ExprEngine::getCXXThisRegion(const CXXMethodDecl *decl,
|
|||
void ExprEngine::CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME,
|
||||
ExplodedNode *Pred,
|
||||
ExplodedNodeSet &Dst) {
|
||||
ExplodedNodeSet Tmp;
|
||||
Visit(ME->GetTemporaryExpr(), Pred, Tmp);
|
||||
for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
|
||||
const ProgramState *state = (*I)->getState();
|
||||
const Expr *tempExpr = ME->GetTemporaryExpr()->IgnoreParens();
|
||||
const ProgramState *state = Pred->getState();
|
||||
|
||||
// Bind the temporary object to the value of the expression. Then bind
|
||||
// the expression to the location of the object.
|
||||
SVal V = state->getSVal(ME->GetTemporaryExpr());
|
||||
// Bind the temporary object to the value of the expression. Then bind
|
||||
// the expression to the location of the object.
|
||||
SVal V = state->getSVal(tempExpr);
|
||||
|
||||
const MemRegion *R =
|
||||
svalBuilder.getRegionManager().getCXXTempObjectRegion(ME,
|
||||
Pred->getLocationContext());
|
||||
const MemRegion *R =
|
||||
svalBuilder.getRegionManager().getCXXTempObjectRegion(ME,
|
||||
Pred->getLocationContext());
|
||||
|
||||
state = state->bindLoc(loc::MemRegionVal(R), V);
|
||||
MakeNode(Dst, ME, Pred, state->BindExpr(ME, loc::MemRegionVal(R)));
|
||||
}
|
||||
state = state->bindLoc(loc::MemRegionVal(R), V);
|
||||
MakeNode(Dst, ME, Pred, state->BindExpr(ME, loc::MemRegionVal(R)));
|
||||
}
|
||||
|
||||
void ExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E,
|
||||
|
|
|
@ -50,7 +50,7 @@ int *f2() {
|
|||
int *f3() {
|
||||
int x1;
|
||||
int *const &x2 = &x1; // expected-note {{binding reference variable 'x2' here}}
|
||||
return x2; // expected-warning {{address of stack memory associated with local variable 'x1' returned}}
|
||||
return x2; // expected-warning {{address of stack memory associated with local variable 'x1' returned}} expected-warning {{Address of stack memory associated with local variable 'x1' returned to caller}}
|
||||
}
|
||||
|
||||
const int *f4() {
|
||||
|
|
Loading…
Reference in New Issue