1218887Sdim//==- BlockCounter.h - ADT for counting block visits ---------------*- C++ -*-//
2218887Sdim//
3218887Sdim//                     The LLVM Compiler Infrastructure
4218887Sdim//
5218887Sdim// This file is distributed under the University of Illinois Open Source
6218887Sdim// License. See LICENSE.TXT for details.
7218887Sdim//
8218887Sdim//===----------------------------------------------------------------------===//
9218887Sdim//
10218887Sdim//  This file defines BlockCounter, an abstract data type used to count
11218887Sdim//  the number of times a given block has been visited along a path
12218887Sdim//  analyzed by CoreEngine.
13218887Sdim//
14218887Sdim//===----------------------------------------------------------------------===//
15218887Sdim
16218887Sdim#ifndef LLVM_CLANG_GR_BLOCKCOUNTER
17218887Sdim#define LLVM_CLANG_GR_BLOCKCOUNTER
18218887Sdim
19218887Sdimnamespace llvm {
20218887Sdim  class BumpPtrAllocator;
21218887Sdim}
22218887Sdim
23218887Sdimnamespace clang {
24218887Sdim
25218887Sdimclass StackFrameContext;
26218887Sdim
27218887Sdimnamespace ento {
28218887Sdim
29226633Sdim/// \class BlockCounter
30226633Sdim/// \brief An abstract data type used to count the number of times a given
31226633Sdim/// block has been visited along a path analyzed by CoreEngine.
32218887Sdimclass BlockCounter {
33226633Sdim  void *Data;
34218887Sdim
35226633Sdim  BlockCounter(void *D) : Data(D) {}
36218887Sdim
37218887Sdimpublic:
38218887Sdim  BlockCounter() : Data(0) {}
39218887Sdim
40218887Sdim  unsigned getNumVisited(const StackFrameContext *CallSite,
41218887Sdim                         unsigned BlockID) const;
42218887Sdim
43218887Sdim  class Factory {
44226633Sdim    void *F;
45218887Sdim  public:
46218887Sdim    Factory(llvm::BumpPtrAllocator& Alloc);
47218887Sdim    ~Factory();
48218887Sdim
49218887Sdim    BlockCounter GetEmptyCounter();
50218887Sdim    BlockCounter IncrementCount(BlockCounter BC,
51218887Sdim                                  const StackFrameContext *CallSite,
52218887Sdim                                  unsigned BlockID);
53218887Sdim  };
54218887Sdim
55218887Sdim  friend class Factory;
56218887Sdim};
57218887Sdim
58218887Sdim} // end GR namespace
59218887Sdim
60218887Sdim} // end clang namespace
61218887Sdim
62218887Sdim#endif
63