[cfe-commits] r57654 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h include/clang/Analysis/PathSensitive/GRState.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicStore.cpp lib/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Thu Oct 16 17:03:18 PDT 2008
Author: kremenek
Date: Thu Oct 16 19:03:18 2008
New Revision: 57654
URL: http://llvm.org/viewvc/llvm-project?rev=57654&view=rev
Log:
Add transfer function support for ObjCIvarRefExpr.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
cfe/trunk/lib/Analysis/BasicStore.cpp
cfe/trunk/lib/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=57654&r1=57653&r2=57654&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Thu Oct 16 19:03:18 2008
@@ -441,6 +441,8 @@
}
// Get the lvalue of an expression.
+ // FIXME: Remove this method, and used specialized versions of GetLValue
+ // in GRStateManager.
RVal GetLValue(const GRState* St, const Expr* Ex) {
return StateMgr.GetLValue(St, Ex);
}
@@ -521,6 +523,10 @@
/// VisitMemberExpr - Transfer function for member expressions.
void VisitMemberExpr(MemberExpr* M, NodeTy* Pred, NodeSet& Dst,bool asLValue);
+ /// VisitObjCIvarRefExpr - Transfer function logic for ObjCIvarRefExprs.
+ void VisitObjCIvarRefExpr(ObjCIvarRefExpr* DR, NodeTy* Pred, NodeSet& Dst,
+ bool asLValue);
+
/// VisitObjCMessageExpr - Transfer function for ObjC message expressions.
void VisitObjCMessageExpr(ObjCMessageExpr* ME, NodeTy* Pred, NodeSet& Dst);
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h?rev=57654&r1=57653&r2=57654&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Thu Oct 16 19:03:18 2008
@@ -346,11 +346,17 @@
}
// Get the lvalue of expression.
+ // FIXME: Remove this method, and implement specialized versions for
+ // specific Decls.
RVal GetLValue(const GRState* St, const Expr* Ex) {
// Forward to store manager. The lvalue of an expression is determined by
// the store manager.
return StoreMgr->getLValue(St, Ex);
}
+
+ RVal GetLValue(const GRState* St, ObjCIvarDecl* D, RVal Base) {
+ return StoreMgr->getLValue(St, D, Base);
+ }
// Methods that query & manipulate the Environment.
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Store.h?rev=57654&r1=57653&r2=57654&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Thu Oct 16 19:03:18 2008
@@ -30,6 +30,7 @@
class LiveVariables;
class Stmt;
class Expr;
+class ObjCIvarDecl;
class MemRegion;
class MemRegionManager;
@@ -47,7 +48,12 @@
virtual LVal getLVal(const VarDecl* VD) = 0;
// Get the lvalue of an expression.
+ // FIXME: Remove this method, and implement specialized versions for
+ // specific Decls.
virtual RVal getLValue(const GRState* St, const Expr* Ex) = 0;
+
+ virtual RVal getLValue(const GRState* St, const ObjCIvarDecl* D, RVal Base)=0;
+
virtual Store
RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=57654&r1=57653&r2=57654&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Thu Oct 16 19:03:18 2008
@@ -48,6 +48,7 @@
}
virtual RVal getLValue(const GRState* St, const Expr* Ex);
+ virtual RVal getLValue(const GRState* St, const ObjCIvarDecl* D, RVal Base);
virtual Store
RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
@@ -154,6 +155,11 @@
return UnknownVal();
}
+RVal BasicStoreManager::getLValue(const GRState* St, const ObjCIvarDecl* D,
+ RVal Base) {
+ return UnknownVal();
+}
+
Store BasicStoreManager::SetRVal(Store store, LVal LV, RVal V) {
switch (LV.getSubKind()) {
case lval::MemRegionKind: {
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=57654&r1=57653&r2=57654&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Thu Oct 16 19:03:18 2008
@@ -350,10 +350,13 @@
break;
}
- case Stmt::MemberExprClass: {
+ case Stmt::MemberExprClass:
VisitMemberExpr(cast<MemberExpr>(S), Pred, Dst, false);
break;
- }
+
+ case Stmt::ObjCIvarRefExprClass:
+ VisitObjCIvarRefExpr(cast<ObjCIvarRefExpr>(S), Pred, Dst, false);
+ break;
case Stmt::ObjCMessageExprClass: {
VisitObjCMessageExpr(cast<ObjCMessageExpr>(S), Pred, Dst);
@@ -417,6 +420,10 @@
VisitDeclRefExpr(cast<DeclRefExpr>(Ex), Pred, Dst, true);
return;
+ case Stmt::ObjCIvarRefExprClass:
+ VisitObjCIvarRefExpr(cast<ObjCIvarRefExpr>(Ex), Pred, Dst, true);
+ return;
+
case Stmt::UnaryOperatorClass:
VisitUnaryOperator(cast<UnaryOperator>(Ex), Pred, Dst, true);
return;
@@ -1223,6 +1230,30 @@
}
//===----------------------------------------------------------------------===//
+// Transfer function: Objective-C ivar references.
+//===----------------------------------------------------------------------===//
+
+void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex,
+ NodeTy* Pred, NodeSet& Dst,
+ bool asLValue) {
+
+ Expr* Base = cast<Expr>(Ex->getBase());
+ NodeSet Tmp;
+ Visit(Base, Pred, Tmp);
+
+ for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ const GRState* St = GetState(*I);
+ RVal BaseVal = GetRVal(St, Base);
+ RVal location = StateMgr.GetLValue(St, Ex->getDecl(), BaseVal);
+
+ if (asLValue)
+ MakeNode(Dst, Ex, *I, SetRVal(St, Ex, location));
+ else
+ EvalLoad(Dst, Ex, *I, St, location);
+ }
+}
+
+//===----------------------------------------------------------------------===//
// Transfer function: Objective-C message expressions.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list