handle CXXFunctionalCastExpr in visitLValue and Environment.

llvm-svn: 120143
This commit is contained in:
Zhongxing Xu 2010-11-25 03:18:57 +00:00
parent 7514633c26
commit 33f13595c9
3 changed files with 27 additions and 0 deletions

View File

@ -78,6 +78,10 @@ SVal Environment::GetSVal(const Stmt *E, ValueManager& ValMgr) const {
case Stmt::CXXBindTemporaryExprClass:
E = cast<CXXBindTemporaryExpr>(E)->getSubExpr();
continue;
case Stmt::CXXFunctionalCastExprClass:
E = cast<CXXFunctionalCastExpr>(E)->getSubExpr();
continue;
// Handle all other Stmt* using a lookup.
default:

View File

@ -1158,6 +1158,18 @@ void GRExprEngine::VisitLValue(const Expr* Ex, ExplodedNode* Pred,
break;
}
case Stmt::CXXConstructExprClass: {
const CXXConstructExpr *expr = cast<CXXConstructExpr>(Ex);
VisitCXXConstructExpr(expr, 0, Pred, Dst, true);
break;
}
case Stmt::CXXFunctionalCastExprClass: {
const CXXFunctionalCastExpr *expr = cast<CXXFunctionalCastExpr>(Ex);
VisitLValue(expr->getSubExpr(), Pred, Dst);
break;
}
case Stmt::CXXTemporaryObjectExprClass: {
const CXXTemporaryObjectExpr *expr = cast<CXXTemporaryObjectExpr>(Ex);
VisitCXXTemporaryObjectExpr(expr, Pred, Dst, true);

View File

@ -17,3 +17,14 @@ void f1() {
}
}
void f2() {
const A &x = A(3);
if (x.getx() == 3) {
int *p = 0;
*p = 3; // expected-warning{{Dereference of null pointer}}
} else {
int *p = 0;
*p = 3; // no-warning
}
}