Make sense.<br><br><div class="gmail_quote">2009/12/24 Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Zhongxing,<br>
<br>
Alternatively we could store the callsite information in the StackFrameContext. That would obviate the need for a side map, and would make LocationContext's capture the context-sensitivity directly. Keeping that information in the LocationContext is also useful when we start thinking about emitting diagnostics.<br>
<font color="#888888"><br>
Ted<br>
</font><div><div></div><div class="h5"><br>
On Dec 23, 2009, at 6:25 PM, Zhongxing Xu wrote:<br>
<br>
> Author: zhongxingxu<br>
> Date: Wed Dec 23 20:25:21 2009<br>
> New Revision: 92116<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=92116&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=92116&view=rev</a><br>
> Log:<br>
> Inter-procedural analysis: now we can return from the callee.<br>
><br>
> Modified:<br>
> cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h<br>
> cfe/trunk/lib/Analysis/CallInliner.cpp<br>
><br>
> Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h?rev=92116&r1=92115&r2=92116&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h?rev=92116&r1=92115&r2=92116&view=diff</a><br>
><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h (original)<br>
> +++ cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h Wed Dec 23 20:25:21 2009<br>
> @@ -211,6 +211,8 @@<br>
> /// of this builder.<br>
> CFGBlock* getBlock() const { return &B; }<br>
><br>
> + unsigned getIndex() const { return Idx; }<br>
> +<br>
> void setAuditor(GRAuditor* A) { Auditor = A; }<br>
><br>
> const GRState* GetState(ExplodedNode* Pred) const {<br>
> @@ -401,7 +403,7 @@<br>
> };<br>
><br>
> class GREndPathNodeBuilder {<br>
> - GRCoreEngine& Eng;<br>
> + GRCoreEngine &Eng;<br>
> CFGBlock& B;<br>
> ExplodedNode* Pred;<br>
><br>
> @@ -414,6 +416,8 @@<br>
><br>
> ~GREndPathNodeBuilder();<br>
><br>
> + GRWorkList &getWorkList() { return *Eng.WList; }<br>
> +<br>
> ExplodedNode* getPredecessor() const { return Pred; }<br>
><br>
> GRBlockCounter getBlockCounter() const {<br>
><br>
> Modified: cfe/trunk/lib/Analysis/CallInliner.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallInliner.cpp?rev=92116&r1=92115&r2=92116&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallInliner.cpp?rev=92116&r1=92115&r2=92116&view=diff</a><br>
><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Analysis/CallInliner.cpp (original)<br>
> +++ cfe/trunk/lib/Analysis/CallInliner.cpp Wed Dec 23 20:25:21 2009<br>
> @@ -19,6 +19,11 @@<br>
><br>
> namespace {<br>
> class CallInliner : public Checker {<br>
> +<br>
> + /// CallSitePosition - Map the call site to its CFG block and stmt index. This<br>
> + /// is used when exiting from a callee.<br>
> + llvm::DenseMap<const Stmt *, std::pair<CFGBlock*,unsigned> > CallSitePosition;<br>
> +<br>
> public:<br>
> static void *getTag() {<br>
> static int x;<br>
> @@ -26,6 +31,7 @@<br>
> }<br>
><br>
> virtual bool EvalCallExpr(CheckerContext &C, const CallExpr *CE);<br>
> + virtual void EvalEndPath(GREndPathNodeBuilder &B,void *tag,GRExprEngine &Eng);<br>
> };<br>
> }<br>
><br>
> @@ -77,6 +83,37 @@<br>
><br>
> Builder.HasGeneratedNode = true;<br>
><br>
> + // Record the call site position.<br>
> + CallSitePosition[CE] = std::make_pair(Builder.getBlock(), Builder.getIndex());<br>
> return true;<br>
> }<br>
><br>
> +void CallInliner::EvalEndPath(GREndPathNodeBuilder &B, void *tag,<br>
> + GRExprEngine &Eng) {<br>
> + const GRState *state = B.getState();<br>
> + ExplodedNode *Pred = B.getPredecessor();<br>
> + const StackFrameContext *LocCtx =<br>
> + cast<StackFrameContext>(Pred->getLocationContext());<br>
> +<br>
> + const Stmt *CE = LocCtx->getCallSite();<br>
> +<br>
> + // Check if this is the top level stack frame.<br>
> + if (!LocCtx->getParent())<br>
> + return;<br>
> +<br>
> + PostStmt NodeLoc(CE, LocCtx->getParent());<br>
> +<br>
> + bool isNew;<br>
> + ExplodedNode *Succ = Eng.getGraph().getNode(NodeLoc, state, &isNew);<br>
> + Succ->addPredecessor(Pred, Eng.getGraph());<br>
> +<br>
> + assert(CallSitePosition.find(CE) != CallSitePosition.end());<br>
> +<br>
> + // When creating the new work list unit, increment the statement index to<br>
> + // point to the statement after the CallExpr.<br>
> + if (isNew)<br>
> + B.getWorkList().Enqueue(Succ, *CallSitePosition[CE].first,<br>
> + CallSitePosition[CE].second + 1);<br>
> +<br>
> + B.HasGeneratedNode = true;<br>
> +}<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
</div></div></blockquote></div><br>