ClearBlue
SymbolicExprGraphModel.h
1 /*
2  * Developed by Qingkai Shi
3  * Copy Right by Prism Research Group, HKUST and State Key Lab for Novel
4  * Software Tech., Nanjing University.
5  */
6 
7 #ifndef IR_SEG_SYMBOLICEXPRGRAPHMODEL_H
8 #define IR_SEG_SYMBOLICEXPRGRAPHMODEL_H
9 
10 #include <cstdbool>
11 #include <iostream>
12 #include <llvm/IR/BasicBlock.h>
13 #include <map>
14 #include <string>
15 #include <unordered_map>
16 #include <utility>
17 
18 #include "IR/SEG/SymbolicExprGraph.h"
19 #include "IR/SEG/SymbolicExprGraphSolver.h"
20 #include "SMT/SMTFactory.h"
21 #include "SMT/SMTModel.h"
22 
23 using namespace llvm;
24 
26 private:
27  typedef std::unordered_map<const SEGNodeBase *,
28  std::pair<std::string, std::string>>
29  ModelMapTy;
30  ModelMapTy SEGModel;
31 
32 public:
33  SymbolicExprGraphModel(SymbolicExprGraphSolver &Solver, SMTModel &SMTModel) {
34  for (unsigned int i = 0; i < SMTModel.size(); i++) {
35  // Trigger move ctor of pair to reduce string copy overhead
36  std::pair<std::string, std::string> DebugInfo(
37  SMTModel.getModelDbgInfo(i));
38 
39  if (DebugInfo.first != "") {
40  // Here we capture only assignment to string symbols (i.e. Terminal
41  // nodes)
42  // TODO: Assignment for other types of symbols to be handled if required
43  const SEGNodeBase *n = Solver.getNodeFromSymbol(DebugInfo.first);
44  if (n != nullptr)
45  SEGModel[n] = DebugInfo;
46  }
47  }
48  }
49 
50  typedef ModelMapTy::const_iterator const_iterator;
51 
52  inline const_iterator begin() const { return SEGModel.begin(); }
53 
54  inline const_iterator end() const { return SEGModel.end(); }
55 };
56 
57 #endif
SymbolicExprGraphSolver
Definition: SymbolicExprGraphSolver.h:48
SymbolicExprGraphSolver::getNodeFromSymbol
const SEGNodeBase * getNodeFromSymbol(std::string Symbol)
return the SEG node for the given symbol
Definition: SymbolicExprGraphSolver.h:163
SymbolicExprGraphModel
Definition: SymbolicExprGraphModel.h:25
SEGNodeBase
The node base of symbolic expression graph.
Definition: SymbolicExprGraph.h:244