clang: lib/StaticAnalyzer/Core/BlockCounter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16#include "llvm/ADT/ImmutableMap.h"

17

18using namespace clang;

19using namespace ento;

20

21namespace {

22

23class CountKey {

26

27public:

30

31 bool operator==(const CountKey &RHS) const {

32 return (CallSite == RHS.CallSite) && (BlockID == RHS.BlockID);

33 }

34

35 bool operator<(const CountKey &RHS) const {

36 return std::tie(CallSite, BlockID) < std::tie(RHS.CallSite, RHS.BlockID);

37 }

38

39 void Profile(llvm::FoldingSetNodeID &ID) const {

40 ID.AddPointer(CallSite);

41 ID.AddInteger(BlockID);

42 }

43};

44

45}

46

47typedef llvm::ImmutableMap<CountKey, unsigned> CountMap;

48

50 return CountMap(static_castCountMap::TreeTy\*\(D));

51}

52

53static inline CountMap::Factory& GetFactory(void *F) {

54 return *static_castCountMap::Factory\*\(F);

55}

56

58 unsigned BlockID) const {

60 CountMap::data_type* T = M.lookup(CountKey(CallSite, BlockID));

61 return T ? *T : 0;

62}

63

65 F = new CountMap::Factory(Alloc);

66}

67

69 delete static_castCountMap::Factory\*\(F);

70}

71

75 unsigned BlockID) {

77 CountKey(CallSite, BlockID),

78 BC.getNumVisited(CallSite, BlockID)+1).getRoot());

79}

80

84}

static CountMap GetMap(void *D)

llvm::ImmutableMap< CountKey, unsigned > CountMap

static CountMap::Factory & GetFactory(void *F)

It represents a stack frame of the call stack (based on CallEvent).

BlockCounter IncrementCount(BlockCounter BC, const StackFrameContext *CallSite, unsigned BlockID)

Factory(llvm::BumpPtrAllocator &Alloc)

BlockCounter GetEmptyCounter()

An abstract data type used to count the number of times a given block has been visited along a path a...

unsigned getNumVisited(const StackFrameContext *CallSite, unsigned BlockID) const

BlockID

The various types of blocks that can occur within a API notes file.

The JSON file list parser is used to communicate input to InstallAPI.

bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)

bool operator<(DeclarationName LHS, DeclarationName RHS)

Ordering on two declaration names.

const FunctionProtoType * T