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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59152 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/Environment.cpp b/lib/Analysis/Environment.cpp
index 0effe3a..a67965e 100644
--- a/lib/Analysis/Environment.cpp
+++ b/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 @@
break;
}
- // Handle all other Expr* using a lookup.
+ // Handle all other Stmt* using a lookup.
default:
break;
@@ -70,26 +70,30 @@
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());
+ 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);
}
-
- case Stmt::IntegerLiteralClass: {
- return NonLoc::MakeVal(BasicVals, cast<IntegerLiteral>(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 @@
// 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();