File tree 2 files changed +27
-1
lines changed
include/llvm/ExecutionEngine/Orc
unittests/ExecutionEngine/Orc 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -1438,7 +1438,7 @@ class ExecutionSession {
1438
1438
1439
1439
public:
1440
1440
// / For reporting errors.
1441
- using ErrorReporter = std::function <void (Error)>;
1441
+ using ErrorReporter = unique_function <void (Error)>;
1442
1442
1443
1443
// / Send a result to the remote.
1444
1444
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 {};
24
24
25
25
namespace {
26
26
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
+
27
53
TEST_F (CoreAPIsStandardTest, JITDylibAddToLinkOrder) {
28
54
// Check that the JITDylib::addToLinkOrder methods behave as expected.
29
55
auto &JD2 = ES.createBareJITDylib (" JD2" );
You can’t perform that action at this time.
0 commit comments