clang API Documentation

BlockCounter.h
Go to the documentation of this file.
00001 //==- BlockCounter.h - ADT for counting block visits ---------------*- C++ -*-//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  This file defines BlockCounter, an abstract data type used to count
00011 //  the number of times a given block has been visited along a path
00012 //  analyzed by CoreEngine.
00013 //
00014 //===----------------------------------------------------------------------===//
00015 
00016 #ifndef LLVM_CLANG_GR_BLOCKCOUNTER
00017 #define LLVM_CLANG_GR_BLOCKCOUNTER
00018 
00019 namespace llvm {
00020   class BumpPtrAllocator;
00021 }
00022 
00023 namespace clang {
00024 
00025 class StackFrameContext;
00026 
00027 namespace ento {
00028 
00029 /// \class BlockCounter
00030 /// \brief An abstract data type used to count the number of times a given
00031 /// block has been visited along a path analyzed by CoreEngine.
00032 class BlockCounter {
00033   void *Data;
00034 
00035   BlockCounter(void *D) : Data(D) {}
00036 
00037 public:
00038   BlockCounter() : Data(0) {}
00039 
00040   unsigned getNumVisited(const StackFrameContext *CallSite, 
00041                          unsigned BlockID) const;
00042 
00043   class Factory {
00044     void *F;
00045   public:
00046     Factory(llvm::BumpPtrAllocator& Alloc);
00047     ~Factory();
00048 
00049     BlockCounter GetEmptyCounter();
00050     BlockCounter IncrementCount(BlockCounter BC, 
00051                                   const StackFrameContext *CallSite,
00052                                   unsigned BlockID);
00053   };
00054 
00055   friend class Factory;
00056 };
00057 
00058 } // end GR namespace
00059 
00060 } // end clang namespace
00061 
00062 #endif