1 //==- BlockCounter.h - ADT for counting block visits ---------------*- 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 BlockCounter, an abstract data type used to count
11 //  the number of times a given block has been visited along a path
12 //  analyzed by CoreEngine.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_BLOCKCOUNTER_H
17 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_BLOCKCOUNTER_H
18 
19 #include "llvm/Support/Allocator.h"
20 
21 namespace clang {
22 
23 class StackFrameContext;
24 
25 namespace ento {
26 
27 /// \class BlockCounter
28 /// \brief An abstract data type used to count the number of times a given
29 /// block has been visited along a path analyzed by CoreEngine.
30 class BlockCounter {
31   void *Data;
32 
BlockCounter(void * D)33   BlockCounter(void *D) : Data(D) {}
34 
35 public:
BlockCounter()36   BlockCounter() : Data(nullptr) {}
37 
38   unsigned getNumVisited(const StackFrameContext *CallSite,
39                          unsigned BlockID) const;
40 
41   class Factory {
42     void *F;
43   public:
44     Factory(llvm::BumpPtrAllocator& Alloc);
45     ~Factory();
46 
47     BlockCounter GetEmptyCounter();
48     BlockCounter IncrementCount(BlockCounter BC,
49                                   const StackFrameContext *CallSite,
50                                   unsigned BlockID);
51   };
52 
53   friend class Factory;
54 };
55 
56 } // end GR namespace
57 
58 } // end clang namespace
59 
60 #endif
61