[cfe-commits] r48773 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h lib/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Tue Mar 25 09:07:42 PDT 2008
Author: kremenek
Date: Tue Mar 25 11:07:41 2008
New Revision: 48773
URL: http://llvm.org/viewvc/llvm-project?rev=48773&view=rev
Log:
Tweak to transfer function for ObjCMessageExpr: handle both instance methods
and message expressions with a specified receiver.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
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=48773&r1=48772&r2=48773&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Tue Mar 25 11:07:41 2008
@@ -401,10 +401,13 @@
/// VisitObjCMessageExpr - Transfer function for ObjC message expressions.
void VisitObjCMessageExpr(ObjCMessageExpr* ME, NodeTy* Pred, NodeSet& Dst);
- void VisitObjCMessageExprHelper(ObjCMessageExpr* ME,
- ObjCMessageExpr::arg_iterator I,
- ObjCMessageExpr::arg_iterator E,
- NodeTy* Pred, NodeSet& Dst);
+ void VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME,
+ ObjCMessageExpr::arg_iterator I,
+ ObjCMessageExpr::arg_iterator E,
+ NodeTy* Pred, NodeSet& Dst);
+
+ void VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME, NodeTy* Pred,
+ NodeSet& Dst);
/// VisitCast - Transfer function logic for all casts (implicit and explicit).
void VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst);
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=48773&r1=48772&r2=48773&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Tue Mar 25 11:07:41 2008
@@ -1084,10 +1084,10 @@
void GRExprEngine::VisitObjCMessageExpr(ObjCMessageExpr* ME, NodeTy* Pred,
NodeSet& Dst){
- VisitObjCMessageExprHelper(ME, ME->arg_begin(), ME->arg_end(), Pred, Dst);
+ VisitObjCMessageExprArgHelper(ME, ME->arg_begin(), ME->arg_end(), Pred, Dst);
}
-void GRExprEngine::VisitObjCMessageExprHelper(ObjCMessageExpr* ME,
+void GRExprEngine::VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME,
ObjCMessageExpr::arg_iterator AI,
ObjCMessageExpr::arg_iterator AE,
NodeTy* Pred, NodeSet& Dst) {
@@ -1095,71 +1095,17 @@
// Process the receiver.
- Expr* Receiver = ME->getReceiver();
- NodeSet Tmp;
- VisitLVal(Receiver, Pred, Tmp);
-
- // FIXME: More logic for the processing the method call.
-
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI) {
-
- ValueState* St = GetState(*NI);
- RVal L = GetLVal(St, Receiver);
-
- // Check for undefined control-flow or calls to NULL.
-
- if (L.isUndef()) {
- NodeTy* N = Builder->generateNode(ME, St, *NI);
-
- if (N) {
- N->markAsSink();
- UndefReceivers.insert(N);
- }
-
- continue;
- }
-
- // Check for any arguments that are uninitialized/undefined.
-
- bool badArg = false;
-
- for (ObjCMessageExpr::arg_iterator I = ME->arg_begin(), E = ME->arg_end();
- I != E; ++I) {
-
- if (GetRVal(St, *I).isUndef()) {
-
- NodeTy* N = Builder->generateNode(ME, St, *NI);
-
- if (N) {
- N->markAsSink();
- MsgExprUndefArgs[N] = *I;
- }
-
- badArg = true;
- break;
- }
-
- RVal V = GetRVal(St, *I);
- }
-
- if (badArg)
- continue;
+ if (Expr* Receiver = ME->getReceiver()) {
+ NodeSet Tmp;
+ VisitLVal(Receiver, Pred, Tmp);
+
+ for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ VisitObjCMessageExprDispatchHelper(ME, *NI, Dst);
- // FIXME: Eventually we will properly handle the effects of a message
- // expr. For now invalidate all arguments passed in by references.
-
- for (ObjCMessageExpr::arg_iterator I = ME->arg_begin(), E = ME->arg_end();
- I != E; ++I) {
-
- RVal V = GetRVal(St, *I);
-
- if (isa<LVal>(V))
- St = SetRVal(St, cast<LVal>(V), UnknownVal());
- }
-
- MakeNode(Dst, ME, *NI, St);
+ return;
}
-
+
+ VisitObjCMessageExprDispatchHelper(ME, Pred, Dst);
return;
}
@@ -1169,9 +1115,67 @@
++AI;
for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
- VisitObjCMessageExprHelper(ME, AI, AE, *NI, Dst);
+ VisitObjCMessageExprArgHelper(ME, AI, AE, *NI, Dst);
}
+void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME,
+ NodeTy* Pred, NodeSet& Dst) {
+
+
+ // FIXME: More logic for the processing the method call.
+
+ ValueState* St = GetState(Pred);
+
+ if (Expr* Receiver = ME->getReceiver()) {
+
+ RVal L = GetLVal(St, Receiver);
+
+ // Check for undefined control-flow or calls to NULL.
+
+ if (L.isUndef()) {
+ NodeTy* N = Builder->generateNode(ME, St, Pred);
+
+ if (N) {
+ N->markAsSink();
+ UndefReceivers.insert(N);
+ }
+
+ return;
+ }
+ }
+
+ // Check for any arguments that are uninitialized/undefined.
+
+ for (ObjCMessageExpr::arg_iterator I = ME->arg_begin(), E = ME->arg_end();
+ I != E; ++I) {
+
+ if (GetRVal(St, *I).isUndef()) {
+
+ NodeTy* N = Builder->generateNode(ME, St, Pred);
+
+ if (N) {
+ N->markAsSink();
+ MsgExprUndefArgs[N] = *I;
+ }
+
+ return;
+ }
+ }
+
+ // FIXME: Eventually we will properly handle the effects of a message
+ // expr. For now invalidate all arguments passed in by references.
+
+ for (ObjCMessageExpr::arg_iterator I = ME->arg_begin(), E = ME->arg_end();
+ I != E; ++I) {
+
+ RVal V = GetRVal(St, *I);
+
+ if (isa<LVal>(V))
+ St = SetRVal(St, cast<LVal>(V), UnknownVal());
+ }
+
+ MakeNode(Dst, ME, Pred, St);
+}
void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
More information about the cfe-commits
mailing list