ClearBlue
SEGReturnNode.h
1 /*
2  * SEGReturnNode.h
3  *
4  * Qingkai
5  *
6  * This node is to model a super return that merge all returned value.
7  */
8 
9 #ifndef IR_SEG_SEGRETURNNODE_H
10 #define IR_SEG_SEGRETURNNODE_H
11 
12 #include <llvm/IR/BasicBlock.h>
13 
14 #include <unordered_map>
15 #include <unordered_set>
16 
17 #include "CBAccessPath.h"
18 #include "IR/SEG/SymbolicExprGraph.h"
19 
20 using namespace llvm;
21 
22 class SEGReturnSite;
23 
25 class SEGReturnNode : public SEGOperandNode {
26  friend class SEGSerializer;
27  friend class SEGHash;
28 
29 protected:
30  std::unordered_set<SEGReturnSite *> RetInsts;
31  std::unordered_map<const SEGNodeBase *, SEGReturnSite *> RetNodeSiteMap;
32 
33  SEGReturnNode(SEGObjectKind, Type *Ty, SymbolicExprGraph *SEG, BasicBlock *BB,
34  bool fromDisk);
35  SEGReturnNode(SEGObjectKind, Value *Val, Type *Ty, SymbolicExprGraph *SEG,
36  BasicBlock *BB, bool fromDisk);
37 
38  friend class SymbolicExprGraph;
39 
40 public:
41  virtual ~SEGReturnNode();
42 
43  void addReturnNodeSitePair(const SEGNodeBase *Node, SEGReturnSite *Site);
44 
45  SEGReturnSite *getReturnSite(const SEGNodeBase *Node) const;
46 
47  virtual int64_t getIndex() const = 0;
48 
49 public:
50  static bool classof(const SEGObject *O) {
51  return O->getKind() >= SEGOBJK_ReturnBegin &&
52  O->getKind() <= SEGOBJK_ReturnEnd;
53  }
54 };
55 
57 
58 private:
59  SEGCommonReturnNode(Type *Ty, SymbolicExprGraph *SEG, BasicBlock *BB,
60  bool fromDisk);
61 
62  friend class SymbolicExprGraph;
63 
64 public:
65  virtual int64_t getIndex() const {
66  assert(false);
67  return 0;
68  }
69 
70 public:
71  static bool classof(const SEGObject *O) {
72  return O->getKind() == SEGOBJK_CommonReturn;
73  }
74 };
75 
77 private:
78  // set by SEG
79  int64_t Index = -1;
80 
81  CBAccessPath AP;
82 
83  SEGPseudoReturnNode(Value *Val, Type *Ty, SymbolicExprGraph *SEG,
84  BasicBlock *BB, bool fromDisk);
85 
86  friend class SymbolicExprGraph;
87  friend class SEGSerializer;
88 
89 public:
90  virtual int64_t getIndex() const { return Index; }
91 
92  const CBAccessPath &getAccessPath() const { return AP; }
93 
94  CBAccessPath &getAccessPath() { return AP; }
95 
96 public:
97  static bool classof(const SEGObject *O) {
98  return O->getKind() == SEGOBJK_PseudoReturn;
99  }
100 };
101 
102 #endif
SEGOperandNode
Definition: SymbolicExprGraph.h:456
SymbolicExprGraph
Definition: SymbolicExprGraph.h:708
SEGCommonReturnNode
Definition: SEGReturnNode.h:56
SEGReturnSite
Definition: SEGReturnSite.h:18
SEGObject
Definition: SymbolicExprGraph.h:76
CBAccessPath
Definition: CBAccessPath.h:22
SEGPseudoReturnNode
Definition: SEGReturnNode.h:76
SEGReturnNode
The return node.
Definition: SEGReturnNode.h:25
SEGNodeBase
The node base of symbolic expression graph.
Definition: SymbolicExprGraph.h:244