1 //==- GRWorkList.h - Worklist class used by GRCoreEngine -----------*- C++ -*-//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines GRWorkList, a pure virtual class that represents an opaque
11 // worklist used by GRCoreEngine to explore the reachability state space.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_GR_GRWORKLIST
16 #define LLVM_CLANG_GR_GRWORKLIST
18 #include "clang/GR/PathSensitive/GRBlockCounter.h"
28 class ExplodedNodeImpl
;
30 class GRWorkListUnit
{
32 GRBlockCounter Counter
;
33 const CFGBlock
* Block
;
34 unsigned BlockIdx
; // This is the index of the next statement.
37 GRWorkListUnit(ExplodedNode
* N
, GRBlockCounter C
,
38 const CFGBlock
* B
, unsigned idx
)
44 explicit GRWorkListUnit(ExplodedNode
* N
, GRBlockCounter C
)
50 ExplodedNode
* getNode() const { return Node
; }
51 GRBlockCounter
getBlockCounter() const { return Counter
; }
52 const CFGBlock
* getBlock() const { return Block
; }
53 unsigned getIndex() const { return BlockIdx
; }
57 GRBlockCounter CurrentCounter
;
59 virtual ~GRWorkList();
60 virtual bool hasWork() const = 0;
62 virtual void Enqueue(const GRWorkListUnit
& U
) = 0;
64 void Enqueue(ExplodedNode
* N
, const CFGBlock
* B
, unsigned idx
) {
65 Enqueue(GRWorkListUnit(N
, CurrentCounter
, B
, idx
));
68 void Enqueue(ExplodedNode
* N
) {
69 Enqueue(GRWorkListUnit(N
, CurrentCounter
));
72 virtual GRWorkListUnit
Dequeue() = 0;
74 void setBlockCounter(GRBlockCounter C
) { CurrentCounter
= C
; }
75 GRBlockCounter
getBlockCounter() const { return CurrentCounter
; }
81 virtual bool Visit(const GRWorkListUnit
&U
) = 0;
83 virtual bool VisitItemsInWorkList(Visitor
&V
) = 0;
85 static GRWorkList
*MakeDFS();
86 static GRWorkList
*MakeBFS();
87 static GRWorkList
*MakeBFSBlockDFSContents();
92 } // end clang namespace