File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -71,9 +71,11 @@ static inline char* GetEnv(const char* Var_Name) {
71
71
#include " llvm/ADT/SmallString.h"
72
72
#include " llvm/ADT/StringRef.h"
73
73
#include " llvm/ADT/Twine.h"
74
+ #include " llvm/BinaryFormat/MachO.h"
74
75
#include " llvm/Config/llvm-config.h"
75
76
#include " llvm/ExecutionEngine/JITSymbol.h"
76
77
#include " llvm/ExecutionEngine/Orc/LLJIT.h"
78
+ #include " llvm/Object/MachO.h"
77
79
#include " llvm/Support/Casting.h"
78
80
#include " llvm/Support/Path.h"
79
81
Original file line number Diff line number Diff line change @@ -311,3 +311,25 @@ if (llvm::sys::RunningOnValgrind())
311
311
delete ExtInterp;
312
312
#endif
313
313
}
314
+
315
+ TEST (InterpreterTest, InterpreterExceptions) {
316
+ Cpp::CreateInterpreter ();
317
+ EXPECT_TRUE (Cpp::Declare (" int f() { throw 1; return 2; }" ) == 0 );
318
+ EXPECT_TRUE (
319
+ Cpp::Process (
320
+ " int ex() { try { f(); return 0; } catch(...){return 1;} }" ) == 0 );
321
+ EXPECT_EQ (Cpp::Evaluate (" ex()" ), 1 )
322
+ << " Failed to catch exceptions in interpreter" ;
323
+ }
324
+
325
+ TEST (InterpreterTest, InterpreterExceptionsCompiledCode) {
326
+ Cpp::CreateInterpreter ();
327
+ bool caught = false ;
328
+ try {
329
+ EXPECT_TRUE (Cpp::Declare (" int f() { throw 1; return 2; }" ) == 0 );
330
+ EXPECT_TRUE (Cpp::Process (" int res = f();" ) == 0 );
331
+ } catch (...) {
332
+ caught = true ;
333
+ }
334
+ EXPECT_TRUE (caught) << " Unable to catch exception coming from interpreter" ;
335
+ }
You can’t perform that action at this time.
0 commit comments