clang: lib/Analysis/CFGReachabilityAnalysis.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

17#include "llvm/ADT/BitVector.h"

18

19using namespace clang;

20

22 const CFG &cfg)

23 : analyzed(cfg.getNumBlockIDs(), false) {}

24

27 const unsigned DstBlockID = Dst->getBlockID();

28

29

30 if (!analyzed[DstBlockID]) {

31 mapReachability(Dst);

32 analyzed[DstBlockID] = true;

33 }

34

35

36 return reachable[DstBlockID][Src->getBlockID()];

37}

38

39

40

41void CFGReverseBlockReachabilityAnalysis::mapReachability(const CFGBlock *Dst) {

43 llvm::BitVector visited(analyzed.size());

44

45 ReachableSet &DstReachability = reachable[Dst->getBlockID()];

46 DstReachability.resize(analyzed.size(), false);

47

48

49

50 worklist.push_back(Dst);

51 bool firstRun = true;

52

53 while (!worklist.empty()) {

54 const CFGBlock *block = worklist.pop_back_val();

55

57 continue;

59

60

61 if (!firstRun) {

62

63 DstReachability[block->getBlockID()] = true;

64 }

65 else

66 firstRun = false;

67

68

70 e = block->pred_end(); i != e; ++i) {

71 if (*i)

72 worklist.push_back(*i);

73 }

74 }

75}

Represents a single basic block in a source-level CFG.

AdjacentBlocks::const_iterator const_pred_iterator

pred_iterator pred_begin()

unsigned getBlockID() const

CFGReverseBlockReachabilityAnalysis(const CFG &cfg)

Definition CFGReachabilityAnalysis.cpp:21

bool isReachable(const CFGBlock *Src, const CFGBlock *Dst)

Returns true if the block 'Dst' can be reached from block 'Src'.

Definition CFGReachabilityAnalysis.cpp:25

Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.

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