diff options
| -rw-r--r-- | clang/Analysis/GRExprEngine.cpp | 29 | ||||
| -rw-r--r-- | clang/Analysis/ValueState.cpp | 30 |
2 files changed, 29 insertions, 30 deletions
diff --git a/clang/Analysis/GRExprEngine.cpp b/clang/Analysis/GRExprEngine.cpp index 4479ecf30b2..c0f53fe8c70 100644 --- a/clang/Analysis/GRExprEngine.cpp +++ b/clang/Analysis/GRExprEngine.cpp @@ -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; @@ -1203,20 +1203,7 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) { VisitCast(C, C->getSubExpr(), Pred, 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); diff --git a/clang/Analysis/ValueState.cpp b/clang/Analysis/ValueState.cpp index ab208ff0fe2..7f3e733dbb9 100644 --- a/clang/Analysis/ValueState.cpp +++ b/clang/Analysis/ValueState.cpp @@ -264,6 +264,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 @@ -332,9 +342,23 @@ RVal ValueStateManager::GetRVal(ValueState St, Expr* E) { 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) { |

