optimization: no longer create ExplodedNodes for IntegerLiteral and

CharacterLiteral expressions.

llvm-svn: 47617
This commit is contained in:
Ted Kremenek 2008-02-26 19:17:09 +00:00
parent 060e79c729
commit 9b69ed398b
2 changed files with 29 additions and 30 deletions

View File

@ -1170,7 +1170,7 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
default: default:
// Cases we intentionally have "default" handle: // Cases we intentionally have "default" handle:
// AddrLabelExpr // AddrLabelExpr, IntegerLiteral, CharacterLiteral
Dst.Add(Pred); // No-op. Simply propagate the current state unchanged. Dst.Add(Pred); // No-op. Simply propagate the current state unchanged.
break; break;
@ -1203,20 +1203,7 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
VisitCast(C, C->getSubExpr(), Pred, Dst); VisitCast(C, C->getSubExpr(), Pred, Dst);
break; break;
} }
// While explicitly creating a node+state for visiting a CharacterLiteral
// seems wasteful, it also solves a bunch of problems when handling
// the ?, &&, and ||.
case Stmt::CharacterLiteralClass: {
CharacterLiteral* C = cast<CharacterLiteral>(S);
StateTy St = Pred->getState();
NonLVal X = NonLVal::MakeVal(ValMgr, C->getValue(), C->getType(),
C->getLoc());
Nodify(Dst, C, Pred, SetRVal(St, C, X));
break;
}
// FIXME: ChooseExpr is really a constant. We need to fix // FIXME: ChooseExpr is really a constant. We need to fix
// the CFG do not model them as explicit control-flow. // the CFG do not model them as explicit control-flow.
@ -1244,18 +1231,6 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
VisitDeclStmt(cast<DeclStmt>(S), Pred, Dst); VisitDeclStmt(cast<DeclStmt>(S), Pred, Dst);
break; break;
// While explicitly creating a node+state for visiting an IntegerLiteral
// seems wasteful, it also solves a bunch of problems when handling
// the ?, &&, and ||.
case Stmt::IntegerLiteralClass: {
StateTy St = Pred->getState();
IntegerLiteral* I = cast<IntegerLiteral>(S);
NonLVal X = NonLVal::MakeVal(ValMgr, I);
Nodify(Dst, I, Pred, SetRVal(St, I, X));
break;
}
case Stmt::ImplicitCastExprClass: { case Stmt::ImplicitCastExprClass: {
ImplicitCastExpr* C = cast<ImplicitCastExpr>(S); ImplicitCastExpr* C = cast<ImplicitCastExpr>(S);
VisitCast(C, C->getSubExpr(), Pred, Dst); VisitCast(C, C->getSubExpr(), Pred, Dst);

View File

@ -264,6 +264,16 @@ RVal ValueStateManager::GetRVal(ValueState St, Expr* E) {
return UnknownVal(); return UnknownVal();
} }
case Stmt::CharacterLiteralClass: {
CharacterLiteral* C = cast<CharacterLiteral>(E);
return NonLVal::MakeVal(ValMgr, C->getValue(), C->getType(),
C->getLoc());
}
case Stmt::IntegerLiteralClass: {
return NonLVal::MakeVal(ValMgr, cast<IntegerLiteral>(E));
}
// Casts where the source and target type are the same // Casts where the source and target type are the same
// are no-ops. We blast through these to get the descendant // are no-ops. We blast through these to get the descendant
@ -332,9 +342,23 @@ RVal ValueStateManager::GetRVal(ValueState St, Expr* E) {
RVal ValueStateManager::GetBlkExprRVal(ValueState St, Expr* E) { RVal ValueStateManager::GetBlkExprRVal(ValueState St, Expr* E) {
assert (!isa<ParenExpr>(E)); assert (!isa<ParenExpr>(E));
ValueState::ExprBindingsTy::TreeTy* T = St->BlockExprBindings.SlimFind(E); switch (E->getStmtClass()) {
return T ? T->getValue().second : UnknownVal(); case Stmt::CharacterLiteralClass: {
CharacterLiteral* C = cast<CharacterLiteral>(E);
return NonLVal::MakeVal(ValMgr, C->getValue(), C->getType(),
C->getLoc());
}
case Stmt::IntegerLiteralClass: {
return NonLVal::MakeVal(ValMgr, cast<IntegerLiteral>(E));
}
default: {
ValueState::ExprBindingsTy::TreeTy* T = St->BlockExprBindings.SlimFind(E);
return T ? T->getValue().second : UnknownVal();
}
}
} }
RVal ValueStateManager::GetLVal(ValueState St, Expr* E) { RVal ValueStateManager::GetLVal(ValueState St, Expr* E) {