CoreEngine.h revision 8ad8c546372fe602708cb7ceeaf0ebbb866735c6
1//==- CoreEngine.h - Path-Sensitive Dataflow Engine ----------------*- C++ -*-//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file defines a generic engine for intraprocedural, path-sensitive,
11//  dataflow analysis via graph reachability.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_GR_COREENGINE
16#define LLVM_CLANG_GR_COREENGINE
17
18#include "clang/AST/Expr.h"
19#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
20#include "clang/StaticAnalyzer/Core/PathSensitive/WorkList.h"
21#include "clang/StaticAnalyzer/Core/PathSensitive/BlockCounter.h"
22#include "llvm/ADT/OwningPtr.h"
23
24namespace clang {
25
26class ProgramPointTag;
27
28namespace ento {
29
30class NodeBuilder;
31
32//===----------------------------------------------------------------------===//
33/// CoreEngine - Implements the core logic of the graph-reachability
34///   analysis. It traverses the CFG and generates the ExplodedGraph.
35///   Program "states" are treated as opaque void pointers.
36///   The template class CoreEngine (which subclasses CoreEngine)
37///   provides the matching component to the engine that knows the actual types
38///   for states.  Note that this engine only dispatches to transfer functions
39///   at the statement and block-level.  The analyses themselves must implement
40///   any transfer function logic and the sub-expression level (if any).
41class CoreEngine {
42  friend class CommonNodeBuilder;
43  friend class NodeBuilder;
44  friend class StmtNodeBuilder;
45  friend class GenericNodeBuilderImpl;
46  friend class BranchNodeBuilder;
47  friend class IndirectGotoNodeBuilder;
48  friend class SwitchNodeBuilder;
49  friend class EndOfFunctionNodeBuilder;
50  friend class CallEnterNodeBuilder;
51  friend class CallExitNodeBuilder;
52
53public:
54  typedef std::vector<std::pair<BlockEdge, const ExplodedNode*> >
55            BlocksExhausted;
56
57  typedef std::vector<std::pair<const CFGBlock*, const ExplodedNode*> >
58            BlocksAborted;
59
60private:
61
62  SubEngine& SubEng;
63
64  /// G - The simulation graph.  Each node is a (location,state) pair.
65  llvm::OwningPtr<ExplodedGraph> G;
66
67  /// WList - A set of queued nodes that need to be processed by the
68  ///  worklist algorithm.  It is up to the implementation of WList to decide
69  ///  the order that nodes are processed.
70  WorkList* WList;
71
72  /// BCounterFactory - A factory object for created BlockCounter objects.
73  ///   These are used to record for key nodes in the ExplodedGraph the
74  ///   number of times different CFGBlocks have been visited along a path.
75  BlockCounter::Factory BCounterFactory;
76
77  /// The locations where we stopped doing work because we visited a location
78  ///  too many times.
79  BlocksExhausted blocksExhausted;
80
81  /// The locations where we stopped because the engine aborted analysis,
82  /// usually because it could not reason about something.
83  BlocksAborted blocksAborted;
84
85  void generateNode(const ProgramPoint &Loc,
86                    const ProgramState *State,
87                    ExplodedNode *Pred);
88
89  void HandleBlockEdge(const BlockEdge &E, ExplodedNode *Pred);
90  void HandleBlockEntrance(const BlockEntrance &E, ExplodedNode *Pred);
91  void HandleBlockExit(const CFGBlock *B, ExplodedNode *Pred);
92  void HandlePostStmt(const CFGBlock *B, unsigned StmtIdx, ExplodedNode *Pred);
93
94  void HandleBranch(const Stmt *Cond, const Stmt *Term, const CFGBlock *B,
95                    ExplodedNode *Pred);
96  void HandleCallEnter(const CallEnter &L, const CFGBlock *Block,
97                       unsigned Index, ExplodedNode *Pred);
98  void HandleCallExit(const CallExit &L, ExplodedNode *Pred);
99
100private:
101  CoreEngine(const CoreEngine&); // Do not implement.
102  CoreEngine& operator=(const CoreEngine&);
103
104public:
105  /// Construct a CoreEngine object to analyze the provided CFG using
106  ///  a DFS exploration of the exploded graph.
107  CoreEngine(SubEngine& subengine)
108    : SubEng(subengine), G(new ExplodedGraph()),
109      WList(WorkList::makeBFS()),
110      BCounterFactory(G->getAllocator()) {}
111
112  /// Construct a CoreEngine object to analyze the provided CFG and to
113  ///  use the provided worklist object to execute the worklist algorithm.
114  ///  The CoreEngine object assumes ownership of 'wlist'.
115  CoreEngine(WorkList* wlist, SubEngine& subengine)
116    : SubEng(subengine), G(new ExplodedGraph()), WList(wlist),
117      BCounterFactory(G->getAllocator()) {}
118
119  ~CoreEngine() {
120    delete WList;
121  }
122
123  /// getGraph - Returns the exploded graph.
124  ExplodedGraph& getGraph() { return *G.get(); }
125
126  /// takeGraph - Returns the exploded graph.  Ownership of the graph is
127  ///  transferred to the caller.
128  ExplodedGraph* takeGraph() { return G.take(); }
129
130  /// ExecuteWorkList - Run the worklist algorithm for a maximum number of
131  ///  steps.  Returns true if there is still simulation state on the worklist.
132  bool ExecuteWorkList(const LocationContext *L, unsigned Steps,
133                       const ProgramState *InitState);
134  void ExecuteWorkListWithInitialState(const LocationContext *L,
135                                       unsigned Steps,
136                                       const ProgramState *InitState,
137                                       ExplodedNodeSet &Dst);
138
139  // Functions for external checking of whether we have unfinished work
140  bool wasBlockAborted() const { return !blocksAborted.empty(); }
141  bool wasBlocksExhausted() const { return !blocksExhausted.empty(); }
142  bool hasWorkRemaining() const { return wasBlocksExhausted() ||
143                                         WList->hasWork() ||
144                                         wasBlockAborted(); }
145
146  /// Inform the CoreEngine that a basic block was aborted because
147  /// it could not be completely analyzed.
148  void addAbortedBlock(const ExplodedNode *node, const CFGBlock *block) {
149    blocksAborted.push_back(std::make_pair(block, node));
150  }
151
152  WorkList *getWorkList() const { return WList; }
153
154  BlocksExhausted::const_iterator blocks_exhausted_begin() const {
155    return blocksExhausted.begin();
156  }
157  BlocksExhausted::const_iterator blocks_exhausted_end() const {
158    return blocksExhausted.end();
159  }
160  BlocksAborted::const_iterator blocks_aborted_begin() const {
161    return blocksAborted.begin();
162  }
163  BlocksAborted::const_iterator blocks_aborted_end() const {
164    return blocksAborted.end();
165  }
166
167  /// Enqueue the results of the node builder onto the work list.
168  void enqueue(ExplodedNodeSet &NB);
169};
170
171struct NodeBuilderContext {
172  CoreEngine &Eng;
173  const CFGBlock *Block;
174  ExplodedNode *ContextPred;
175  NodeBuilderContext(CoreEngine &E, const CFGBlock *B, ExplodedNode *N)
176    : Eng(E), Block(B), ContextPred(N) { assert(B); assert(!N->isSink()); }
177};
178
179/// This is the simplest builder which generates nodes in the ExplodedGraph.
180class NodeBuilder {
181protected:
182  friend class StmtNodeBuilder;
183
184  const NodeBuilderContext &C;
185
186  /// Specifies if the builder results have been finalized. For example, if it
187  /// is set to false, autotransitions are yet to be generated.
188  bool Finalized;
189
190  bool HasGeneratedNodes;
191
192  /// \brief The frontier set - a set of nodes which need to be propagated after
193  /// the builder dies.
194  ExplodedNodeSet &Frontier;
195
196  BlockCounter getBlockCounter() const { return C.Eng.WList->getBlockCounter();}
197
198  /// Checkes if the results are ready.
199  virtual bool checkResults() {
200    if (!Finalized)
201      return false;
202    return true;
203  }
204
205  bool haveNoSinksInFrontier() {
206    for (iterator I = Frontier.begin(), E = Frontier.end(); I != E; ++I) {
207      if ((*I)->isSink())
208        return false;
209    }
210    return true;
211  }
212
213  /// Allow subclasses to finalize results before result_begin() is executed.
214  virtual void finalizeResults() {}
215
216  ExplodedNode *generateNodeImpl(const ProgramPoint &PP,
217                                 const ProgramState *State,
218                                 ExplodedNode *Pred,
219                                 bool MarkAsSink = false);
220
221public:
222  NodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet,
223              const NodeBuilderContext &Ctx, bool F = true)
224    : C(Ctx), Finalized(F), HasGeneratedNodes(false), Frontier(DstSet) {
225  //  assert(DstSet.empty());
226    Frontier.Add(SrcNode);
227  }
228
229  NodeBuilder(const ExplodedNodeSet &SrcSet, ExplodedNodeSet &DstSet,
230              const NodeBuilderContext &Ctx, bool F = true)
231    : C(Ctx), Finalized(F), HasGeneratedNodes(false), Frontier(DstSet) {
232    //assert(DstSet.empty());
233    //assert(!SrcSet.empty());
234    Frontier.insert(SrcSet);
235    assert(haveNoSinksInFrontier());
236  }
237
238  virtual ~NodeBuilder() {}
239
240  /// \brief Generates a node in the ExplodedGraph.
241  ///
242  /// When a node is marked as sink, the exploration from the node is stopped -
243  /// the node becomes the last node on the path.
244  ExplodedNode *generateNode(const ProgramPoint &PP,
245                             const ProgramState *State,
246                             ExplodedNode *Pred,
247                             bool MarkAsSink = false) {
248    return generateNodeImpl(PP, State, Pred, MarkAsSink);
249  }
250
251  // TODO: will get removed.
252  bool hasGeneratedNodes() const {
253    return HasGeneratedNodes;
254  }
255
256  const ExplodedNodeSet &getResults() {
257    finalizeResults();
258    assert(checkResults());
259    return Frontier;
260  }
261
262  typedef ExplodedNodeSet::iterator iterator;
263  /// \brief Iterators through the results frontier.
264  inline iterator begin() {
265    finalizeResults();
266    assert(checkResults());
267    return Frontier.begin();
268  }
269  inline iterator end() {
270    finalizeResults();
271    return Frontier.end();
272  }
273
274  /// \brief Return the CFGBlock associated with this builder.
275  const CFGBlock *getBlock() const { return C.Block; }
276
277  const NodeBuilderContext &getContext() { return C; }
278
279  /// \brief Returns the number of times the current basic block has been
280  /// visited on the exploded graph path.
281  unsigned getCurrentBlockCount() const {
282    return getBlockCounter().getNumVisited(
283                    C.ContextPred->getLocationContext()->getCurrentStackFrame(),
284                    C.Block->getBlockID());
285  }
286};
287
288class CommonNodeBuilder {
289protected:
290  ExplodedNode *Pred;
291  CoreEngine& Eng;
292
293  CommonNodeBuilder(CoreEngine* E, ExplodedNode *P) : Pred(P), Eng(*E) {}
294  BlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter(); }
295};
296
297
298class PureStmtNodeBuilder: public NodeBuilder {
299public:
300  PureStmtNodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet,
301                      const NodeBuilderContext &Ctx)
302    : NodeBuilder(SrcNode, DstSet, Ctx) {}
303
304  ExplodedNode *generateNode(const Stmt *S,
305                             ExplodedNode *Pred,
306                             const ProgramState *St,
307                             ProgramPoint::Kind K = ProgramPoint::PostStmtKind,
308                             bool MarkAsSink = false,
309                             const ProgramPointTag *tag = 0,
310                             bool Purging = false) {
311    if (Purging) {
312      assert(K == ProgramPoint::PostStmtKind);
313      K = ProgramPoint::PostPurgeDeadSymbolsKind;
314    }
315
316    const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K,
317                                  Pred->getLocationContext(), tag);
318    return generateNodeImpl(L, St, Pred, MarkAsSink);
319  }
320};
321
322class StmtNodeBuilder : public NodeBuilder {
323  const unsigned Idx;
324
325public:
326  bool PurgingDeadSymbols;
327  bool BuildSinks;
328  // TODO: Remove the flag. We should be able to use the method in the parent.
329  bool hasGeneratedNode;
330  ProgramPoint::Kind PointKind;
331  const ProgramPointTag *Tag;
332
333  void GenerateAutoTransition(ExplodedNode *N);
334
335  StmtNodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet,
336                  unsigned idx, const NodeBuilderContext &Ctx)
337    : NodeBuilder(SrcNode, DstSet, Ctx), Idx(idx),
338      PurgingDeadSymbols(false), BuildSinks(false), hasGeneratedNode(false),
339      PointKind(ProgramPoint::PostStmtKind), Tag(0) {}
340
341  virtual ~StmtNodeBuilder();
342
343  ExplodedNode *generateNode(const Stmt *S,
344                             const ProgramState *St,
345                             ExplodedNode *Pred,
346                             ProgramPoint::Kind K,
347                             const ProgramPointTag *tag = 0,
348                             bool MarkAsSink = false) {
349    if (PurgingDeadSymbols)
350      K = ProgramPoint::PostPurgeDeadSymbolsKind;
351
352    const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K,
353                                  Pred->getLocationContext(), tag ? tag : Tag);
354    return generateNodeImpl(L, St, Pred, MarkAsSink);
355  }
356
357  ExplodedNode *generateNode(const Stmt *S,
358                             const ProgramState *St,
359                             ExplodedNode *Pred,
360                             const ProgramPointTag *tag = 0) {
361    return generateNode(S, St, Pred, PointKind, tag);
362  }
363
364  ExplodedNode *generateNode(const ProgramPoint &PP,
365                             const ProgramState *State,
366                             ExplodedNode *Pred) {
367    return generateNodeImpl(PP, State, Pred, false);
368  }
369
370  /// getStmt - Return the current block-level expression associated with
371  ///  this builder.
372  const Stmt *getStmt() const {
373    const CFGStmt *CS = (*C.Block)[Idx].getAs<CFGStmt>();
374    return CS ? CS->getStmt() : 0;
375  }
376
377  unsigned getIndex() const { return Idx; }
378
379  ExplodedNode *MakeNode(ExplodedNodeSet &Dst,
380                         const Stmt *S,
381                         ExplodedNode *Pred,
382                         const ProgramState *St) {
383    return MakeNode(Dst, S, Pred, St, PointKind);
384  }
385
386  ExplodedNode *MakeNode(ExplodedNodeSet &Dst,
387                         const Stmt *S,
388                         ExplodedNode *Pred,
389                         const ProgramState *St,
390                         ProgramPoint::Kind K);
391
392  ExplodedNode *MakeSinkNode(ExplodedNodeSet &Dst,
393                             const Stmt *S,
394                             ExplodedNode *Pred,
395                             const ProgramState *St) {
396    bool Tmp = BuildSinks;
397    BuildSinks = true;
398    ExplodedNode *N = MakeNode(Dst, S, Pred, St);
399    BuildSinks = Tmp;
400    return N;
401  }
402
403  void takeNodes(const ExplodedNodeSet &S) {
404    for (ExplodedNodeSet::iterator I = S.begin(), E = S.end(); I != E; ++I )
405      Frontier.erase(*I);
406  }
407
408  void takeNodes(ExplodedNode *N) {
409    Frontier.erase(N);
410  }
411
412  void addNodes(const ExplodedNodeSet &S) {
413    Frontier.insert(S);
414  }
415
416  void addNodes(ExplodedNode *N) {
417    Frontier.Add(N);
418  }
419};
420
421class BranchNodeBuilder: public NodeBuilder {
422  const CFGBlock *DstT;
423  const CFGBlock *DstF;
424
425  bool InFeasibleTrue;
426  bool InFeasibleFalse;
427
428public:
429  BranchNodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet,
430                    const NodeBuilderContext &C,
431                    const CFGBlock *dstT, const CFGBlock *dstF)
432  : NodeBuilder(SrcNode, DstSet, C), DstT(dstT), DstF(dstF),
433    InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
434
435  BranchNodeBuilder(const ExplodedNodeSet &SrcSet, ExplodedNodeSet &DstSet,
436                    const NodeBuilderContext &C,
437                    const CFGBlock *dstT, const CFGBlock *dstF)
438  : NodeBuilder(SrcSet, DstSet, C), DstT(dstT), DstF(dstF),
439    InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
440
441  ExplodedNode *generateNode(const ProgramState *State, bool branch,
442                             ExplodedNode *Pred);
443
444  const CFGBlock *getTargetBlock(bool branch) const {
445    return branch ? DstT : DstF;
446  }
447
448  void markInfeasible(bool branch) {
449    if (branch)
450      InFeasibleTrue = true;
451    else
452      InFeasibleFalse = true;
453  }
454
455  bool isFeasible(bool branch) {
456    return branch ? !InFeasibleTrue : !InFeasibleFalse;
457  }
458};
459
460class IndirectGotoNodeBuilder {
461  CoreEngine& Eng;
462  const CFGBlock *Src;
463  const CFGBlock &DispatchBlock;
464  const Expr *E;
465  ExplodedNode *Pred;
466
467public:
468  IndirectGotoNodeBuilder(ExplodedNode *pred, const CFGBlock *src,
469                    const Expr *e, const CFGBlock *dispatch, CoreEngine* eng)
470    : Eng(*eng), Src(src), DispatchBlock(*dispatch), E(e), Pred(pred) {}
471
472  class iterator {
473    CFGBlock::const_succ_iterator I;
474
475    friend class IndirectGotoNodeBuilder;
476    iterator(CFGBlock::const_succ_iterator i) : I(i) {}
477  public:
478
479    iterator &operator++() { ++I; return *this; }
480    bool operator!=(const iterator &X) const { return I != X.I; }
481
482    const LabelDecl *getLabel() const {
483      return llvm::cast<LabelStmt>((*I)->getLabel())->getDecl();
484    }
485
486    const CFGBlock *getBlock() const {
487      return *I;
488    }
489  };
490
491  iterator begin() { return iterator(DispatchBlock.succ_begin()); }
492  iterator end() { return iterator(DispatchBlock.succ_end()); }
493
494  ExplodedNode *generateNode(const iterator &I,
495                             const ProgramState *State,
496                             bool isSink = false);
497
498  const Expr *getTarget() const { return E; }
499
500  const ProgramState *getState() const { return Pred->State; }
501};
502
503class SwitchNodeBuilder {
504  CoreEngine& Eng;
505  const CFGBlock *Src;
506  const Expr *Condition;
507  ExplodedNode *Pred;
508
509public:
510  SwitchNodeBuilder(ExplodedNode *pred, const CFGBlock *src,
511                    const Expr *condition, CoreEngine* eng)
512  : Eng(*eng), Src(src), Condition(condition), Pred(pred) {}
513
514  class iterator {
515    CFGBlock::const_succ_reverse_iterator I;
516
517    friend class SwitchNodeBuilder;
518    iterator(CFGBlock::const_succ_reverse_iterator i) : I(i) {}
519
520  public:
521    iterator &operator++() { ++I; return *this; }
522    bool operator!=(const iterator &X) const { return I != X.I; }
523    bool operator==(const iterator &X) const { return I == X.I; }
524
525    const CaseStmt *getCase() const {
526      return llvm::cast<CaseStmt>((*I)->getLabel());
527    }
528
529    const CFGBlock *getBlock() const {
530      return *I;
531    }
532  };
533
534  iterator begin() { return iterator(Src->succ_rbegin()+1); }
535  iterator end() { return iterator(Src->succ_rend()); }
536
537  const SwitchStmt *getSwitch() const {
538    return llvm::cast<SwitchStmt>(Src->getTerminator());
539  }
540
541  ExplodedNode *generateCaseStmtNode(const iterator &I,
542                                     const ProgramState *State);
543
544  ExplodedNode *generateDefaultCaseNode(const ProgramState *State,
545                                        bool isSink = false);
546
547  const Expr *getCondition() const { return Condition; }
548
549  const ProgramState *getState() const { return Pred->State; }
550};
551
552class GenericNodeBuilderImpl {
553protected:
554  CoreEngine &engine;
555  ExplodedNode *pred;
556  ProgramPoint pp;
557  SmallVector<ExplodedNode*, 2> sinksGenerated;
558
559  ExplodedNode *generateNodeImpl(const ProgramState *state,
560                                 ExplodedNode *pred,
561                                 ProgramPoint programPoint,
562                                 bool asSink);
563
564  GenericNodeBuilderImpl(CoreEngine &eng, ExplodedNode *pr, ProgramPoint p)
565    : engine(eng), pred(pr), pp(p), hasGeneratedNode(false) {}
566
567public:
568  bool hasGeneratedNode;
569
570  WorkList &getWorkList() { return *engine.WList; }
571
572  ExplodedNode *getPredecessor() const { return pred; }
573
574  BlockCounter getBlockCounter() const {
575    return engine.WList->getBlockCounter();
576  }
577
578  const SmallVectorImpl<ExplodedNode*> &sinks() const {
579    return sinksGenerated;
580  }
581};
582
583template <typename PP_T>
584class GenericNodeBuilder : public GenericNodeBuilderImpl {
585public:
586  GenericNodeBuilder(CoreEngine &eng, ExplodedNode *pr, const PP_T &p)
587    : GenericNodeBuilderImpl(eng, pr, p) {}
588
589  ExplodedNode *generateNode(const ProgramState *state, ExplodedNode *pred,
590                             const ProgramPointTag *tag, bool asSink) {
591    return generateNodeImpl(state, pred, cast<PP_T>(pp).withTag(tag),
592                            asSink);
593  }
594
595  const PP_T &getProgramPoint() const { return cast<PP_T>(pp); }
596};
597
598class EndOfFunctionNodeBuilder : public CommonNodeBuilder {
599  const CFGBlock &B;
600  const ProgramPointTag *Tag;
601
602public:
603  bool hasGeneratedNode;
604
605public:
606  EndOfFunctionNodeBuilder(const CFGBlock *b, ExplodedNode *N, CoreEngine* e,
607                           const ProgramPointTag *tag = 0)
608    : CommonNodeBuilder(e, N), B(*b), Tag(tag), hasGeneratedNode(false) {}
609
610  ~EndOfFunctionNodeBuilder();
611
612  EndOfFunctionNodeBuilder withCheckerTag(const ProgramPointTag *tag) {
613    return EndOfFunctionNodeBuilder(&B, Pred, &Eng, tag);
614  }
615
616  WorkList &getWorkList() { return *Eng.WList; }
617
618  ExplodedNode *getPredecessor() const { return Pred; }
619
620  unsigned getCurrentBlockCount() const {
621    return getBlockCounter().getNumVisited(
622                            Pred->getLocationContext()->getCurrentStackFrame(),
623                                           B.getBlockID());
624  }
625
626  ExplodedNode *generateNode(const ProgramState *State,
627                             ExplodedNode *P = 0,
628                             const ProgramPointTag *tag = 0);
629
630  void GenerateCallExitNode(const ProgramState *state);
631
632  const CFGBlock *getBlock() const { return &B; }
633
634  const ProgramState *getState() const {
635    return getPredecessor()->getState();
636  }
637};
638
639class CallEnterNodeBuilder {
640  CoreEngine &Eng;
641
642  const ExplodedNode *Pred;
643
644  // The call site. For implicit automatic object dtor, this is the trigger
645  // statement.
646  const Stmt *CE;
647
648  // The context of the callee.
649  const StackFrameContext *CalleeCtx;
650
651  // The parent block of the CallExpr.
652  const CFGBlock *Block;
653
654  // The CFGBlock index of the CallExpr.
655  unsigned Index;
656
657public:
658  CallEnterNodeBuilder(CoreEngine &eng, const ExplodedNode *pred,
659                         const Stmt *s, const StackFrameContext *callee,
660                         const CFGBlock *blk, unsigned idx)
661    : Eng(eng), Pred(pred), CE(s), CalleeCtx(callee), Block(blk), Index(idx) {}
662
663  const ProgramState *getState() const { return Pred->getState(); }
664
665  const LocationContext *getLocationContext() const {
666    return Pred->getLocationContext();
667  }
668
669  const Stmt *getCallExpr() const { return CE; }
670
671  const StackFrameContext *getCalleeContext() const { return CalleeCtx; }
672
673  const CFGBlock *getBlock() const { return Block; }
674
675  unsigned getIndex() const { return Index; }
676
677  void generateNode(const ProgramState *state);
678};
679
680class CallExitNodeBuilder {
681  CoreEngine &Eng;
682  const ExplodedNode *Pred;
683
684public:
685  CallExitNodeBuilder(CoreEngine &eng, const ExplodedNode *pred)
686    : Eng(eng), Pred(pred) {}
687
688  const ExplodedNode *getPredecessor() const { return Pred; }
689
690  const ProgramState *getState() const { return Pred->getState(); }
691
692  void generateNode(const ProgramState *state);
693};
694
695} // end GR namespace
696
697} // end clang namespace
698
699#endif
700