]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Checker/PathSensitive/GRWorkList.h
Improve the Xen para-virtualized device infrastructure of FreeBSD:
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Checker / PathSensitive / GRWorkList.h
1 //==- GRWorkList.h - Worklist class used by GRCoreEngine -----------*- 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 GRWorkList, a pure virtual class that represents an opaque
11 //  worklist used by GRCoreEngine to explore the reachability state space.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_ANALYSIS_GRWORKLIST
16 #define LLVM_CLANG_ANALYSIS_GRWORKLIST
17
18 #include "clang/Checker/PathSensitive/GRBlockCounter.h"
19 #include <cstddef>
20
21 namespace clang {
22   
23 class CFGBlock;
24 class ExplodedNode;
25 class ExplodedNodeImpl;
26
27 class GRWorkListUnit {
28   ExplodedNode* Node;
29   GRBlockCounter Counter;
30   const CFGBlock* Block;
31   unsigned BlockIdx; // This is the index of the next statement.
32
33 public:
34   GRWorkListUnit(ExplodedNode* N, GRBlockCounter C,
35                  const CFGBlock* B, unsigned idx)
36   : Node(N),
37     Counter(C),
38     Block(B),
39     BlockIdx(idx) {}
40
41   explicit GRWorkListUnit(ExplodedNode* N, GRBlockCounter C)
42   : Node(N),
43     Counter(C),
44     Block(NULL),
45     BlockIdx(0) {}
46
47   ExplodedNode* getNode()         const { return Node; }
48   GRBlockCounter    getBlockCounter() const { return Counter; }
49   const CFGBlock*   getBlock()        const { return Block; }
50   unsigned          getIndex()        const { return BlockIdx; }
51 };
52
53 class GRWorkList {
54   GRBlockCounter CurrentCounter;
55 public:
56   virtual ~GRWorkList();
57   virtual bool hasWork() const = 0;
58
59   virtual void Enqueue(const GRWorkListUnit& U) = 0;
60
61   void Enqueue(ExplodedNode* N, const CFGBlock* B, unsigned idx) {
62     Enqueue(GRWorkListUnit(N, CurrentCounter, B, idx));
63   }
64
65   void Enqueue(ExplodedNode* N) {
66     Enqueue(GRWorkListUnit(N, CurrentCounter));
67   }
68
69   virtual GRWorkListUnit Dequeue() = 0;
70
71   void setBlockCounter(GRBlockCounter C) { CurrentCounter = C; }
72   GRBlockCounter getBlockCounter() const { return CurrentCounter; }
73
74   static GRWorkList *MakeDFS();
75   static GRWorkList *MakeBFS();
76   static GRWorkList *MakeBFSBlockDFSContents();
77 };
78 } // end clang namespace
79 #endif