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
64 changes: 52 additions & 12 deletions clang/unittests/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
if(EMSCRIPTEN)
set(LLVM_COMPONENTS_TO_LINK
""
)
set(LLVM_LIBS_TO_LINK
""
)
set(CLANG_LIBS_TO_LINK
clangInterpreter
)
else()
set(LLVM_COMPONENTS_TO_LINK
${LLVM_TARGETS_TO_BUILD}
Core
MC
OrcJIT
Support
TargetParser
)
set(LLVM_LIBS_TO_LINK
LLVMTestingSupport
)
set(CLANG_LIBS_TO_LINK
clangAST
clangBasic
clangInterpreter
clangFrontend
clangSema
)
endif()

add_distinct_clang_unittest(ClangReplInterpreterTests
IncrementalCompilerBuilderTest.cpp
IncrementalProcessingTest.cpp
Expand All @@ -8,24 +39,33 @@ add_distinct_clang_unittest(ClangReplInterpreterTests
EXPORT_SYMBOLS

CLANG_LIBS
clangAST
clangBasic
clangInterpreter
clangFrontend
clangSema
${CLANG_LIBS_TO_LINK}

LINK_LIBS
LLVMTestingSupport
${LLVM_LIBS_TO_LINK}

LLVM_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Core
MC
OrcJIT
Support
TargetParser
${LLVM_COMPONENTS_TO_LINK}
)

if(EMSCRIPTEN)
# Without the above you try to link to LLVMSupport twice, and end
# up with a duplicate symbol error when creating the main module
get_target_property(LINKED_LIBS ClangReplInterpreterTests LINK_LIBRARIES)
list(REMOVE_ITEM LINKED_LIBS LLVMSupport)
set_target_properties(ClangReplInterpreterTests PROPERTIES LINK_LIBRARIES "${LINKED_LIBS}")
target_link_options(ClangReplInterpreterTests
PUBLIC "SHELL: -s MAIN_MODULE=1"
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
PUBLIC "SHELL: -s STACK_SIZE=32mb"
PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
PUBLIC "SHELL: --emrun"
)
set_target_properties(ClangReplInterpreterTests PROPERTIES
SUFFIX ".html"
)
endif()

# Exceptions on Windows are not yet supported.
if(NOT WIN32)
add_subdirectory(ExceptionTests)
Expand Down
6 changes: 6 additions & 0 deletions clang/unittests/Interpreter/CodeCompletionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ class CodeCompletionTest : public InterpreterTestBase {
std::unique_ptr<clang::Interpreter> Interp;

void SetUp() override {
// FIXME : WebAssembly doesn't currently support Jit (see
// https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095).
// so this check of HostSupportsJIT has been skipped
// over until support is added, and HostSupportsJIT can return true.
#ifndef __EMSCRIPTEN__
if (!HostSupportsJIT())
GTEST_SKIP();
#endif
std::unique_ptr<CompilerInstance> CI = cantFail(CB.CreateCpp());
this->Interp = cantFail(clang::Interpreter::create(std::move(CI)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ TEST(IncrementalCompilerBuilder, SetCompilerArgs) {
}

TEST(IncrementalCompilerBuilder, SetTargetTriple) {
// FIXME : This test doesn't current work for Emscripten builds.
// It should be possible to make it work.For details on how it fails and
// the current progress to enable this test see
// the following Github issue https: //
// github.com/llvm/llvm-project/issues/153461
#ifdef __EMSCRIPTEN__
GTEST_SKIP() << "Test fails for Emscipten builds";
#endif
auto CB = clang::IncrementalCompilerBuilder();
CB.SetTargetTriple("armv6-none-eabi");
auto CI = cantFail(CB.CreateCpp());
Expand Down
7 changes: 6 additions & 1 deletion clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ struct OutOfProcInterpreter : public Interpreter {
};

TEST_F(InterpreterExtensionsTest, FindRuntimeInterface) {
// FIXME : WebAssembly doesn't currently support Jit (see
// https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095).
// so this check of HostSupportsJIT has been skipped
// over until support is added, and HostSupportsJIT can return true.
#ifndef __EMSCRIPTEN__
if (!HostSupportsJIT())
GTEST_SKIP();

#endif
clang::IncrementalCompilerBuilder CB;
llvm::Error ErrOut = llvm::Error::success();
auto CI = cantFail(CB.CreateCpp());
Expand Down
24 changes: 24 additions & 0 deletions clang/unittests/Interpreter/InterpreterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ TEST_F(InterpreterTest, DeclsAndStatements) {
}

TEST_F(InterpreterTest, UndoCommand) {
// FIXME : This test doesn't current work for Emscripten builds.
// It should be possible to make it work.For details on how it fails and
// the current progress to enable this test see
// the following Github issue https: //
// github.com/llvm/llvm-project/issues/153461
#ifdef __EMSCRIPTEN__
GTEST_SKIP() << "Test fails for Emscipten builds";
#endif
Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"};

// Create the diagnostic engine with unowned consumer.
Expand Down Expand Up @@ -256,6 +264,14 @@ static NamedDecl *LookupSingleName(Interpreter &Interp, const char *Name) {
}

TEST_F(InterpreterTest, InstantiateTemplate) {
// FIXME : This test doesn't current work for Emscripten builds.
// It should be possible to make it work.For details on how it fails and
// the current progress to enable this test see
// the following Github issue https: //
// github.com/llvm/llvm-project/issues/153461
#ifdef __EMSCRIPTEN__
GTEST_SKIP() << "Test fails for Emscipten builds";
#endif
// FIXME: We cannot yet handle delayed template parsing. If we run with
// -fdelayed-template-parsing we try adding the newly created decl to the
// active PTU which causes an assert.
Expand Down Expand Up @@ -295,6 +311,14 @@ TEST_F(InterpreterTest, InstantiateTemplate) {
}

TEST_F(InterpreterTest, Value) {
// FIXME : This test doesn't current work for Emscripten builds.
// It should be possible to make it work.For details on how it fails and
// the current progress to enable this test see
// the following Github issue https: //
// github.com/llvm/llvm-project/issues/153461
#ifdef __EMSCRIPTEN__
GTEST_SKIP() << "Test fails for Emscipten builds";
#endif
std::vector<const char *> Args = {"-fno-sized-deallocation"};
std::unique_ptr<Interpreter> Interp = createInterpreter(Args);

Expand Down
6 changes: 6 additions & 0 deletions clang/unittests/Interpreter/InterpreterTestFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ class InterpreterTestBase : public ::testing::Test {
}

void SetUp() override {
// FIXME : WebAssembly doesn't currently support Jit (see
// https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095).
// so this check of HostSupportsJIT has been skipped
// over until support is added, and HostSupportsJIT can return true.
#ifndef __EMSCRIPTEN__
if (!HostSupportsJIT())
GTEST_SKIP();
#endif
}

void TearDown() override {}
Expand Down