File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
include/llvm/ExecutionEngine/Orc
unittests/ExecutionEngine/Orc Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -1438,7 +1438,7 @@ class ExecutionSession {
14381438
14391439public:
14401440 // / For reporting errors.
1441- using ErrorReporter = std::function <void (Error)>;
1441+ using ErrorReporter = unique_function <void (Error)>;
14421442
14431443 // / Send a result to the remote.
14441444 using SendResultFunction = unique_function<void (shared::WrapperFunctionResult)>;
Original file line number Diff line number Diff line change @@ -24,6 +24,32 @@ class CoreAPIsStandardTest : public CoreAPIsBasedStandardTest {};
2424
2525namespace {
2626
27+ class CustomError : public ErrorInfo <CustomError> {
28+ public:
29+ static char ID;
30+ void log (raw_ostream &OS) const override { OS << " CustomError" ; }
31+ std::error_code convertToErrorCode () const override { return {}; }
32+ };
33+ char CustomError::ID = 0 ;
34+
35+ TEST_F (CoreAPIsStandardTest, ErrorReporter) {
36+ // Check that errors reported via ExecutionSession::reportError are sent to
37+ // the registered error reporter, and that the error reporter can hold
38+ // uniquely owned state.
39+
40+ Error ReportedError = Error::success ();
41+
42+ ES.setErrorReporter (
43+ // Make sure error reporter can capture uniquely-owned state.
44+ [&, State = std::make_unique<int >(42 )](Error Err) {
45+ ReportedError = joinErrors (std::move (Err), std::move (ReportedError));
46+ });
47+
48+ ES.reportError (make_error<CustomError>());
49+
50+ EXPECT_THAT_ERROR (std::move (ReportedError), Failed<CustomError>());
51+ }
52+
2753TEST_F (CoreAPIsStandardTest, JITDylibAddToLinkOrder) {
2854 // Check that the JITDylib::addToLinkOrder methods behave as expected.
2955 auto &JD2 = ES.createBareJITDylib (" JD2" );
You can’t perform that action at this time.
0 commit comments