diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-11-12 19:21:30 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-11-12 19:21:30 +0000 |
| commit | b94d72a0e3f5249c45f803822396206de0222d5b (patch) | |
| tree | 773650b56d193fdeac0da40f0d42b725254425d3 /clang/lib/Analysis | |
| parent | cd639218e485391225f37c64dafa467773d5458d (diff) | |
| download | bcm5719-llvm-b94d72a0e3f5249c45f803822396206de0222d5b.tar.gz bcm5719-llvm-b94d72a0e3f5249c45f803822396206de0222d5b.zip | |
GRStateRef:
- Rename SetSVal to BindLoc
- Add BindDecl
- Add BindExpr
GRState:
- Environment now binds to Stmt* instead of Expr*. This is needed for processing ObjCForCollectionStmt (essentially the declaration of the the 'element' variable can have an SVal attached to it).
- BindDecl no longer accepts Expr* for the initialization value; use SVal* instead.
llvm-svn: 59152
Diffstat (limited to 'clang/lib/Analysis')
| -rw-r--r-- | clang/lib/Analysis/Environment.cpp | 42 | ||||
| -rw-r--r-- | clang/lib/Analysis/GRState.cpp | 9 |
2 files changed, 25 insertions, 26 deletions
diff --git a/clang/lib/Analysis/Environment.cpp b/clang/lib/Analysis/Environment.cpp index 0effe3ae58f..a67965e35a1 100644 --- a/clang/lib/Analysis/Environment.cpp +++ b/clang/lib/Analysis/Environment.cpp @@ -1,4 +1,4 @@ -//== Environment.cpp - Map from Expr* to Locations/Values -------*- C++ -*--==// +//== Environment.cpp - Map from Stmt* to Locations/Values -------*- C++ -*--==// // // The LLVM Compiler Infrastructure // @@ -18,7 +18,7 @@ using namespace clang; -SVal Environment::GetSVal(Expr* E, BasicValueFactory& BasicVals) const { +SVal Environment::GetSVal(Stmt* E, BasicValueFactory& BasicVals) const { for (;;) { @@ -58,7 +58,7 @@ SVal Environment::GetSVal(Expr* E, BasicValueFactory& BasicVals) const { break; } - // Handle all other Expr* using a lookup. + // Handle all other Stmt* using a lookup. default: break; @@ -70,26 +70,30 @@ SVal Environment::GetSVal(Expr* E, BasicValueFactory& BasicVals) const { return LookupExpr(E); } -SVal Environment::GetBlkExprSVal(Expr* E, BasicValueFactory& BasicVals) const { +SVal Environment::GetBlkExprSVal(Stmt* E, BasicValueFactory& BasicVals) const { - E = E->IgnoreParens(); - - switch (E->getStmtClass()) { - case Stmt::CharacterLiteralClass: { - CharacterLiteral* C = cast<CharacterLiteral>(E); - return NonLoc::MakeVal(BasicVals, C->getValue(), C->getType()); - } - - case Stmt::IntegerLiteralClass: { - return NonLoc::MakeVal(BasicVals, cast<IntegerLiteral>(E)); + while (1) { + switch (E->getStmtClass()) { + case Stmt::ParenExprClass: + E = cast<ParenExpr>(E)->getSubExpr(); + continue; + + case Stmt::CharacterLiteralClass: { + CharacterLiteral* C = cast<CharacterLiteral>(E); + return NonLoc::MakeVal(BasicVals, C->getValue(), C->getType()); + } + + case Stmt::IntegerLiteralClass: { + return NonLoc::MakeVal(BasicVals, cast<IntegerLiteral>(E)); + } + + default: + return LookupBlkExpr(E); } - - default: - return LookupBlkExpr(E); } } -Environment EnvironmentManager::BindExpr(const Environment& Env, Expr* E,SVal V, +Environment EnvironmentManager::BindExpr(const Environment& Env, Stmt* E,SVal V, bool isBlkExpr, bool Invalidate) { assert (E); @@ -115,7 +119,7 @@ EnvironmentManager::RemoveDeadBindings(Environment Env, Stmt* Loc, // Iterate over the block-expr bindings. for (Environment::beb_iterator I = Env.beb_begin(), E = Env.beb_end(); I != E; ++I) { - Expr* BlkExpr = I.getKey(); + Stmt* BlkExpr = I.getKey(); if (Liveness.isLive(Loc, BlkExpr)) { SVal X = I.getData(); diff --git a/clang/lib/Analysis/GRState.cpp b/clang/lib/Analysis/GRState.cpp index 57f9c6b2793..dd296e06765 100644 --- a/clang/lib/Analysis/GRState.cpp +++ b/clang/lib/Analysis/GRState.cpp @@ -73,15 +73,10 @@ const GRState* GRStateManager::BindLoc(const GRState* St, Loc LV, SVal V) { } const GRState* GRStateManager::BindDecl(const GRState* St, const VarDecl* VD, - Expr* Ex, unsigned Count) { + SVal* InitVal, unsigned Count) { Store OldStore = St->getStore(); - Store NewStore; + Store NewStore = StoreMgr->BindDecl(OldStore, VD, InitVal, Count); - if (Ex) - NewStore = StoreMgr->BindDecl(OldStore, VD, Ex, GetSVal(St, Ex), Count); - else - NewStore = StoreMgr->BindDecl(OldStore, VD, Ex); - if (NewStore == OldStore) return St; |

