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:
// Cases we intentionally have "default" handle:
// AddrLabelExpr
// AddrLabelExpr, IntegerLiteral, CharacterLiteral
Dst.Add(Pred); // No-op. Simply propagate the current state unchanged.
break;
@ -1204,19 +1204,6 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
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
// 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);
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: {
ImplicitCastExpr* C = cast<ImplicitCastExpr>(S);
VisitCast(C, C->getSubExpr(), Pred, Dst);

View File

@ -265,6 +265,16 @@ RVal ValueStateManager::GetRVal(ValueState St, Expr* E) {
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
// are no-ops. We blast through these to get the descendant
// subexpression that has a value.
@ -333,8 +343,22 @@ RVal ValueStateManager::GetBlkExprRVal(ValueState St, Expr* E) {
assert (!isa<ParenExpr>(E));
ValueState::ExprBindingsTy::TreeTy* T = St->BlockExprBindings.SlimFind(E);
return T ? T->getValue().second : UnknownVal();
switch (E->getStmtClass()) {
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) {