@@ -29,6 +29,7 @@ class BasicBlock;
2929class Function ;
3030class LLVMContext ;
3131class Module ;
32+ class Type ;
3233class raw_ostream ;
3334class raw_fd_ostream ;
3435} // namespace llvm
@@ -63,6 +64,13 @@ using FLCtoOpcode = std::unordered_map<
6364 std::unordered_map<
6465 unsigned , std::unordered_map<unsigned , std::unordered_set<unsigned >>>>;
6566
67+ enum class MockStrategy {
68+ None, // No mocks are generated
69+ Naive, // For each function call new symbolic value is generated
70+ Deterministic, // Each function is treated as uninterpreted function in SMT.
71+ // Compatible with Z3 solver only
72+ };
73+
6674class Interpreter {
6775public:
6876 enum class GuidanceKind {
@@ -79,6 +87,8 @@ class Interpreter {
7987 std::string LibraryDir;
8088 std::string EntryPoint;
8189 std::string OptSuffix;
90+ std::string MainCurrentName;
91+ std::string MainNameAfterMock;
8292 bool Optimize;
8393 bool Simplify;
8494 bool CheckDivZero;
@@ -88,13 +98,16 @@ class Interpreter {
8898
8999 ModuleOptions (const std::string &_LibraryDir,
90100 const std::string &_EntryPoint, const std::string &_OptSuffix,
91- bool _Optimize, bool _Simplify, bool _CheckDivZero,
92- bool _CheckOvershift, bool _WithFPRuntime,
93- bool _WithPOSIXRuntime)
101+ const std::string &_MainCurrentName,
102+ const std::string &_MainNameAfterMock, bool _Optimize,
103+ bool _Simplify, bool _CheckDivZero, bool _CheckOvershift,
104+ bool _WithFPRuntime, bool _WithPOSIXRuntime)
94105 : LibraryDir(_LibraryDir), EntryPoint(_EntryPoint),
95- OptSuffix (_OptSuffix), Optimize(_Optimize), Simplify(_Simplify),
96- CheckDivZero(_CheckDivZero), CheckOvershift(_CheckOvershift),
97- WithFPRuntime(_WithFPRuntime), WithPOSIXRuntime(_WithPOSIXRuntime) {}
106+ OptSuffix (_OptSuffix), MainCurrentName(_MainCurrentName),
107+ MainNameAfterMock(_MainNameAfterMock), Optimize(_Optimize),
108+ Simplify(_Simplify), CheckDivZero(_CheckDivZero),
109+ CheckOvershift(_CheckOvershift), WithFPRuntime(_WithFPRuntime),
110+ WithPOSIXRuntime(_WithPOSIXRuntime) {}
98111 };
99112
100113 enum LogType {
@@ -112,10 +125,11 @@ class Interpreter {
112125 unsigned MakeConcreteSymbolic;
113126 GuidanceKind Guidance;
114127 std::optional<SarifReport> Paths;
128+ enum MockStrategy MockStrategy;
115129
116130 InterpreterOptions (std::optional<SarifReport> Paths)
117131 : MakeConcreteSymbolic(false ), Guidance(GuidanceKind::NoGuidance),
118- Paths (std::move(Paths)) {}
132+ Paths (std::move(Paths)), MockStrategy(MockStrategy::None) {}
119133 };
120134
121135protected:
@@ -144,7 +158,11 @@ class Interpreter {
144158 const ModuleOptions &opts,
145159 std::set<std::string> &&mainModuleFunctions,
146160 std::set<std::string> &&mainModuleGlobals,
147- FLCtoOpcode &&origInstructions) = 0 ;
161+ FLCtoOpcode &&origInstructions,
162+ const std::set<std::string> &ignoredExternals) = 0 ;
163+
164+ virtual std::map<std::string, llvm::Type *>
165+ getAllExternals (const std::set<std::string> &ignoredExternals) = 0 ;
148166
149167 // supply a tree stream writer which the interpreter will use
150168 // to record the concrete path (as a stream of '0' and '1' bytes).
0 commit comments