Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Interpreter/exports.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-Wl,--export=_ZN4llvm11raw_ostream16SetBufferAndModeEPcmNS0_10BufferKindE
-Wl,--export=_ZN4llvm11raw_ostream5writeEPKcm
-Wl,--export=_ZN4llvm11raw_ostreamD2Ev
-Wl,--export=_ZN4llvm11raw_ostreamlsEm
-Wl,--export=_ZN4llvm15SmallVectorBaseIjE8grow_podEPvmm
-Wl,--export=_ZN4llvm15allocate_bufferEmm
-Wl,--export=_ZN4llvm21logAllUnhandledErrorsENS_5ErrorERNS_11raw_ostreamENS_5TwineE
Expand Down
1 change: 1 addition & 0 deletions unittests/CppInterOp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ if(EMSCRIPTEN)
# --preload-file ${SYSROOT_PATH}/include@/include:
# Preloads the system include directory into the Emscripten virtual filesystem to make headers accessible at runtime.
target_link_options(CppInterOpTests
PUBLIC "SHELL: -fexceptions"
PUBLIC "SHELL: -s MAIN_MODULE=1"
PUBLIC "SHELL: -s WASM_BIGINT"
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
Expand Down
27 changes: 27 additions & 0 deletions unittests/CppInterOp/InterpreterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@ TEST(InterpreterTest, Process) {
clang_Interpreter_dispose(CXI);
}

TEST(InterpreterTest, EmscriptenExceptionHandling) {
#ifndef EMSCRIPTEN
GTEST_SKIP() << "This test is intended to check exception handling for Emscripten builds.";
#endif

std::vector<const char*> Args = {
"-std=c++20",
"-v",
"-fexceptions",
"-fcxx-exceptions",
"-mllvm", "-enable-emscripten-cxx-exceptions",
"-mllvm", "-enable-emscripten-sjlj"
};

Cpp::CreateInterpreter(Args);

const char* tryCatchCode = R"(
try {
throw 1;
} catch (...) {
0;
}
)";

EXPECT_TRUE(Cpp::Process(tryCatchCode) == 0);
}

TEST(InterpreterTest, CreateInterpreter) {
auto* I = Cpp::CreateInterpreter();
EXPECT_TRUE(I);
Expand Down
Loading