diff --git a/clang/unittests/Interpreter/IncrementalProcessingTest.cpp b/clang/unittests/Interpreter/IncrementalProcessingTest.cpp --- a/clang/unittests/Interpreter/IncrementalProcessingTest.cpp +++ b/clang/unittests/Interpreter/IncrementalProcessingTest.cpp @@ -16,6 +16,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Parse/Parser.h" #include "clang/Sema/Sema.h" +#include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Support/MemoryBuffer.h" @@ -28,8 +29,20 @@ using namespace llvm; using namespace clang; +#if defined(_AIX) +#define CLANG_INTERPRETER_NO_SUPPORT_EXEC +#endif + namespace { +bool HostSupportsJit() { + auto J = llvm::orc::LLJITBuilder().create(); + if (J) + return true; + LLVMConsumeError(llvm::wrap(J.takeError())); + return false; +} + // Incremental processing produces several modules, all using the same "main // file". Make sure CodeGen can cope with that, e.g. for static initializers. const char TestProgram1[] = "extern \"C\" int funcForProg1() { return 17; }\n" @@ -50,7 +63,14 @@ return nullptr; } +#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC +TEST(IncrementalProcessing, DISABLED_EmitCXXGlobalInitFunc) { +#else TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) { +#endif + // We cannot execute on the platform. + if (!HostSupportsJit()) + return; std::vector ClangArgv = {"-Xclang", "-emit-llvm-only"}; auto CI = llvm::cantFail(IncrementalCompilerBuilder::create(ClangArgv)); auto Interp = llvm::cantFail(Interpreter::create(std::move(CI))); diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp --- a/clang/unittests/Interpreter/InterpreterTest.cpp +++ b/clang/unittests/Interpreter/InterpreterTest.cpp @@ -40,6 +40,15 @@ REPL_EXTERNAL_VISIBILITY void setGlobal(int val) { Global = val; } namespace { + +bool HostSupportsJit() { + auto J = llvm::orc::LLJITBuilder().create(); + if (J) + return true; + LLVMConsumeError(llvm::wrap(J.takeError())); + return false; +} + using Args = std::vector; static std::unique_ptr createInterpreter(const Args &ExtraArgs = {}, @@ -56,7 +65,14 @@ return std::distance(PTUDecl->decls().begin(), PTUDecl->decls().end()); } +#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC +TEST(InterpreterTest, DISABLED_Sanity) { +#else TEST(InterpreterTest, Sanity) { +#endif + // We cannot execute on the platform. + if (!HostSupportsJit()) + return; std::unique_ptr Interp = createInterpreter(); using PTU = PartialTranslationUnit; @@ -72,7 +88,14 @@ return llvm::cast(D)->getQualifiedNameAsString(); } +#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC +TEST(InterpreterTest, DISABLED_IncrementalInputTopLevelDecls) { +#else TEST(InterpreterTest, IncrementalInputTopLevelDecls) { +#endif + // We cannot execute on the platform. + if (!HostSupportsJit()) + return; std::unique_ptr Interp = createInterpreter(); auto R1 = Interp->Parse("int var1 = 42; int f() { return var1; }"); // gtest doesn't expand into explicit bool conversions. @@ -89,7 +112,14 @@ EXPECT_EQ("var2", DeclToString(*R2DeclRange.begin())); } +#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC +TEST(InterpreterTest, DISABLED_Errors) { +#else TEST(InterpreterTest, Errors) { +#endif + // We cannot execute on the platform. + if (!HostSupportsJit()) + return; Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"}; // Create the diagnostic engine with unowned consumer. @@ -112,7 +142,14 @@ // Here we test whether the user can mix declarations and statements. The // interpreter should be smart enough to recognize the declarations from the // statements and wrap the latter into a declaration, producing valid code. +#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC +TEST(InterpreterTest, DISABLED_DeclsAndStatements) { +#else TEST(InterpreterTest, DeclsAndStatements) { +#endif + // We cannot execute on the platform. + if (!HostSupportsJit()) + return; Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"}; // Create the diagnostic engine with unowned consumer. @@ -134,7 +171,14 @@ EXPECT_TRUE(!!R2); } +#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC +TEST(InterpreterTest, DISABLED_UndoCommand) { +#else TEST(InterpreterTest, UndoCommand) { +#endif + // We cannot execute on the platform. + if (!HostSupportsJit()) + return; Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"}; // Create the diagnostic engine with unowned consumer. @@ -188,14 +232,6 @@ return RawStr.str(); } -static bool HostSupportsJit() { - auto J = llvm::orc::LLJITBuilder().create(); - if (J) - return true; - LLVMConsumeError(llvm::wrap(J.takeError())); - return false; -} - struct LLVMInitRAII { LLVMInitRAII() { llvm::InitializeNativeTarget(); @@ -209,6 +245,9 @@ #else TEST(IncrementalProcessing, FindMangledNameSymbol) { #endif + // We cannot execute on the platform. + if (!HostSupportsJit()) + return; std::unique_ptr Interp = createInterpreter(); @@ -216,11 +255,6 @@ EXPECT_EQ(1U, DeclsSize(PTU.TUPart)); auto R1DeclRange = PTU.TUPart->decls(); - // We cannot execute on the platform. - if (!HostSupportsJit()) { - return; - } - NamedDecl *FD = cast(*R1DeclRange.begin()); // Lower the PTU if (llvm::Error Err = Interp->Execute(PTU)) { @@ -276,6 +310,10 @@ #else TEST(IncrementalProcessing, InstantiateTemplate) { #endif + // We cannot execute on the platform. + if (!HostSupportsJit()) + return; + // 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. @@ -292,11 +330,6 @@ auto PTUDeclRange = PTU.TUPart->decls(); EXPECT_EQ(1, std::distance(PTUDeclRange.begin(), PTUDeclRange.end())); - // We cannot execute on the platform. - if (!HostSupportsJit()) { - return; - } - // Lower the PTU if (llvm::Error Err = Interp->Execute(PTU)) { // We cannot execute on the platform.