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_ANALYSIS_GRWORKLIST
16 #define LLVM_CLANG_ANALYSIS_GRWORKLIST
18 #include "clang/Checker/PathSensitive/GRBlockCounter.h"
25 class ExplodedNodeImpl;
27 class GRWorkListUnit {
29 GRBlockCounter Counter;
30 const CFGBlock* Block;
31 unsigned BlockIdx; // This is the index of the next statement.
34 GRWorkListUnit(ExplodedNode* N, GRBlockCounter C,
35 const CFGBlock* B, unsigned idx)
41 explicit GRWorkListUnit(ExplodedNode* N, GRBlockCounter C)
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; }
54 GRBlockCounter CurrentCounter;
56 virtual ~GRWorkList();
57 virtual bool hasWork() const = 0;
59 virtual void Enqueue(const GRWorkListUnit& U) = 0;
61 void Enqueue(ExplodedNode* N, const CFGBlock* B, unsigned idx) {
62 Enqueue(GRWorkListUnit(N, CurrentCounter, B, idx));
65 void Enqueue(ExplodedNode* N) {
66 Enqueue(GRWorkListUnit(N, CurrentCounter));
69 virtual GRWorkListUnit Dequeue() = 0;
71 void setBlockCounter(GRBlockCounter C) { CurrentCounter = C; }
72 GRBlockCounter getBlockCounter() const { return CurrentCounter; }
74 static GRWorkList *MakeDFS();
75 static GRWorkList *MakeBFS();
76 static GRWorkList *MakeBFSBlockDFSContents();
78 } // end clang namespace