diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-03-25 16:07:41 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-03-25 16:07:41 +0000 |
commit | b9308372e0d40c85cb573c4982fdf5089d89ab6d (patch) | |
tree | 913bf7250a35a93980590eb4d480b05248e18139 /lib/Analysis/GRExprEngine.cpp | |
parent | 23a4f917cd8d1090be7c96c4eda8643086f64d36 (diff) |
Tweak to transfer function for ObjCMessageExpr: handle both instance methods
and message expressions with a specified receiver.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48773 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 136 |
1 files changed, 70 insertions, 66 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 55bfe55119..889d525215 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1084,10 +1084,10 @@ void GRExprEngine::VisitAsmStmtHelperInputs(AsmStmt* A, 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 @@ void GRExprEngine::VisitObjCMessageExprHelper(ObjCMessageExpr* ME, // 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 @@ void GRExprEngine::VisitObjCMessageExprHelper(ObjCMessageExpr* ME, ++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, |