ClearBlue
SEGStoreMemNode.h
1 /*
2  * SEGStoreMemNode.h
3  *
4  * Qingkai
5  *
6  * This node is to model a value stored in a memory.
7  */
8 
9 #ifndef IR_SEG_SEGSTOREMEMNODE_H
10 #define IR_SEG_SEGSTOREMEMNODE_H
11 
12 #include <llvm/IR/BasicBlock.h>
13 #include <llvm/IR/Function.h>
14 #include <llvm/IR/Instructions.h>
15 #include <llvm/IR/Value.h>
16 
17 #include "IR/SEG/SymbolicExprGraph.h"
18 
19 class PersistedSEGStoreMemNode;
20 
21 using namespace llvm;
22 
26 public:
29  SEGStoreMemNode(PersistedSEGStoreMemNode *Node, SymbolicExprGraph *SEG);
30 
31  virtual void assembleSEGObject(std::map<int, SEGObject *> &FuncSEGObjMap) {
32  SEGOperandNode::assembleSEGObject(FuncSEGObjMap);
33  }
34 
35 private:
36  Instruction *StoreSite = nullptr;
37  WrappedInstruction *WrappedStoreSite = nullptr;
38  Value *StoreValue = nullptr;
39  WrappedValue *WrappedStoreValue = nullptr;
40  friend class SymbolicExprGraph;
41 
42  SEGStoreMemNode(Type *Ty, Instruction *StoreSite, Value *StoreVal,
43  BasicBlock *BB, SymbolicExprGraph *SEG);
44 
45 public:
46  ~SEGStoreMemNode() {}
47 
48  virtual PersistedSEGObject *createPersistedObject() const;
49 
50  Instruction *getStoreSite() const { return StoreSite; }
51 
52  WrappedInstruction *getWrappedStoreSite() const { return WrappedStoreSite; }
53 
54  StoreInst *getStoreSiteAsStoreInst() const {
55  if (!StoreSite)
56  return nullptr;
57  return dyn_cast<StoreInst>(StoreSite);
58  }
59 
60  WrappedStoreInst *getWrappedStoreSiteAsStoreInst(void) const {
61  if (!WrappedStoreSite) {
62  return nullptr;
63  }
64  return dyn_cast<WrappedStoreInst>(WrappedStoreSite);
65  }
66 
67  Value *getStoreValue() const { return StoreValue; }
68 
69  WrappedValue *getWrappedStoreValue() const { return WrappedStoreValue; }
70 
71  void dot(raw_fd_ostream &O) const override;
72 
73  virtual Instruction *getLLVMDbgInstruction() const override;
74 
75  virtual std::string getSrcFile() const {
76  if (WrappedStoreSite) {
77  return WrappedStoreSite->getSrcFileName();
78  }
79  return SEGOperandNode::getSrcFile();
80  }
81 
82  virtual std::int32_t getSrcLine() const {
83  if (WrappedStoreSite) {
84  return WrappedStoreSite->getSrcLine();
85  }
86  return SEGOperandNode::getSrcLine();
87  }
88 
89 public:
90  static bool classof(const SEGObject *N) {
91  return N->getKind() == SEGOBJK_StoreMem;
92  }
93 };
94 
95 #endif
SEGStoreMemNode
Definition: SEGStoreMemNode.h:25
SymbolicExprGraph::dot
void dot(const char *FileName) const
Dot this graph to a file with filename.
Definition: SymbolicExprGraph.cpp:1539
SEGOperandNode
Definition: SymbolicExprGraph.h:539
SymbolicExprGraph
Definition: SymbolicExprGraph.h:855
SEGStoreMemNode::assembleSEGObject
virtual void assembleSEGObject(std::map< int, SEGObject * > &FuncSEGObjMap)
Assemble the SEG object's related objects.
Definition: SEGStoreMemNode.h:31
SEGObject
Definition: SymbolicExprGraph.h:87
SEGOperandNode::assembleSEGObject
virtual void assembleSEGObject(std::map< int, SEGObject * > &FuncSEGObjMap)
Assemble the SEG object's related objects.
Definition: SymbolicExprGraph.h:545