forked from OSchip/llvm-project
[ORC] Remove some stale unit test utils.
This code was used to test ORCv1, which has been removed. It is not useful for testing ORCv2.
This commit is contained in:
parent
2ca887de6e
commit
c76e3c319e
|
@ -201,89 +201,6 @@ inline StructType *getDummyStructTy(LLVMContext &Context) {
|
||||||
return StructType::get(ArrayType::get(Type::getInt32Ty(Context), 256));
|
return StructType::get(ArrayType::get(Type::getInt32Ty(Context), 256));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename HandleT, typename ModuleT>
|
|
||||||
class MockBaseLayer {
|
|
||||||
public:
|
|
||||||
|
|
||||||
using ModuleHandleT = HandleT;
|
|
||||||
|
|
||||||
using AddModuleSignature =
|
|
||||||
Expected<ModuleHandleT>(ModuleT M,
|
|
||||||
std::shared_ptr<JITSymbolResolver> R);
|
|
||||||
|
|
||||||
using RemoveModuleSignature = Error(ModuleHandleT H);
|
|
||||||
using FindSymbolSignature = JITSymbol(const std::string &Name,
|
|
||||||
bool ExportedSymbolsOnly);
|
|
||||||
using FindSymbolInSignature = JITSymbol(ModuleHandleT H,
|
|
||||||
const std::string &Name,
|
|
||||||
bool ExportedSymbolsONly);
|
|
||||||
using EmitAndFinalizeSignature = Error(ModuleHandleT H);
|
|
||||||
|
|
||||||
std::function<AddModuleSignature> addModuleImpl;
|
|
||||||
std::function<RemoveModuleSignature> removeModuleImpl;
|
|
||||||
std::function<FindSymbolSignature> findSymbolImpl;
|
|
||||||
std::function<FindSymbolInSignature> findSymbolInImpl;
|
|
||||||
std::function<EmitAndFinalizeSignature> emitAndFinalizeImpl;
|
|
||||||
|
|
||||||
Expected<ModuleHandleT> addModule(ModuleT M,
|
|
||||||
std::shared_ptr<JITSymbolResolver> R) {
|
|
||||||
assert(addModuleImpl &&
|
|
||||||
"addModule called, but no mock implementation was provided");
|
|
||||||
return addModuleImpl(std::move(M), std::move(R));
|
|
||||||
}
|
|
||||||
|
|
||||||
Error removeModule(ModuleHandleT H) {
|
|
||||||
assert(removeModuleImpl &&
|
|
||||||
"removeModule called, but no mock implementation was provided");
|
|
||||||
return removeModuleImpl(H);
|
|
||||||
}
|
|
||||||
|
|
||||||
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
|
|
||||||
assert(findSymbolImpl &&
|
|
||||||
"findSymbol called, but no mock implementation was provided");
|
|
||||||
return findSymbolImpl(Name, ExportedSymbolsOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
|
|
||||||
bool ExportedSymbolsOnly) {
|
|
||||||
assert(findSymbolInImpl &&
|
|
||||||
"findSymbolIn called, but no mock implementation was provided");
|
|
||||||
return findSymbolInImpl(H, Name, ExportedSymbolsOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
Error emitAndFinaliez(ModuleHandleT H) {
|
|
||||||
assert(emitAndFinalizeImpl &&
|
|
||||||
"emitAndFinalize called, but no mock implementation was provided");
|
|
||||||
return emitAndFinalizeImpl(H);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class ReturnNullJITSymbol {
|
|
||||||
public:
|
|
||||||
template <typename... Args>
|
|
||||||
JITSymbol operator()(Args...) const {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename ReturnT>
|
|
||||||
class DoNothingAndReturn {
|
|
||||||
public:
|
|
||||||
DoNothingAndReturn(ReturnT Ret) : Ret(std::move(Ret)) {}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
void operator()(Args...) const { return Ret; }
|
|
||||||
private:
|
|
||||||
ReturnT Ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class DoNothingAndReturn<void> {
|
|
||||||
public:
|
|
||||||
template <typename... Args>
|
|
||||||
void operator()(Args...) const { }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue