From b93eff6645bdac2b8564ecc9d52bc29bd313e2f3 Mon Sep 17 00:00:00 2001 From: Axel Naumann <Axel.Naumann@cern.ch> Date: Sat, 21 Feb 2015 23:09:18 +0100 Subject: [PATCH] Tell which language is enabled (ROOT-7090). --- .../cling/lib/Interpreter/Interpreter.cpp | 17 ++++++--- .../cling/lib/UserInterface/UserInterface.cpp | 36 ++++++++++++++++--- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/Interpreter.cpp b/interpreter/cling/lib/Interpreter/Interpreter.cpp index d39bc6a92c8..7138ec2acc5 100644 --- a/interpreter/cling/lib/Interpreter/Interpreter.cpp +++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp @@ -64,6 +64,10 @@ namespace { } return cling::Interpreter::kExeSuccess; } + + static bool isPracticallyEmptyModule(const llvm::Module* M) { + return M->empty() && M->global_empty() && M->alias_empty(); + } } // unnamed namespace namespace cling { @@ -1134,12 +1138,15 @@ namespace cling { assert(!isInSyntaxOnlyMode() && "Running on what?"); assert(T.getState() == Transaction::kCommitted && "Must be committed"); - T.setExeUnloadHandle(m_Executor.get(), m_Executor->emitToJIT()); - - // Forward to IncrementalExecutor; should not be called by - // anyone except for IncrementalParser. IncrementalExecutor::ExecutionResult ExeRes - = m_Executor->runStaticInitializersOnce(T); + = IncrementalExecutor::kExeSuccess; + if (!isPracticallyEmptyModule(T.getModule())) { + T.setExeUnloadHandle(m_Executor.get(), m_Executor->emitToJIT()); + + // Forward to IncrementalExecutor; should not be called by + // anyone except for IncrementalParser. + ExeRes = m_Executor->runStaticInitializersOnce(T); + } // Reset the module builder to clean up global initializers, c'tors, d'tors ASTContext& C = getCI()->getASTContext(); diff --git a/interpreter/cling/lib/UserInterface/UserInterface.cpp b/interpreter/cling/lib/UserInterface/UserInterface.cpp index 33ec86a1b45..ea042d9861e 100644 --- a/interpreter/cling/lib/UserInterface/UserInterface.cpp +++ b/interpreter/cling/lib/UserInterface/UserInterface.cpp @@ -22,6 +22,9 @@ #include "llvm/Support/Path.h" #include "llvm/Config/config.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Frontend/CompilerInstance.h" + // Fragment copied from LLVM's raw_ostream.cpp #if defined(HAVE_UNISTD_H) # include <unistd.h> @@ -173,10 +176,33 @@ namespace cling { void UserInterface::PrintLogo() { llvm::raw_ostream& outs = m_MetaProcessor->getOuts(); - outs << "\n"; - outs << "****************** CLING ******************" << "\n"; - outs << "* Type C++ code and press enter to run it *" << "\n"; - outs << "* Type .q to exit *" << "\n"; - outs << "*******************************************" << "\n"; + const clang::LangOptions& LangOpts + = m_MetaProcessor->getInterpreter().getCI()->getLangOpts(); + if (LangOpts.CPlusPlus) { + outs << "\n" + "****************** CLING ******************\n" + "* Type C++ code and press enter to run it *\n" + "* Type .q to exit *\n" + "*******************************************\n"; + } else { + outs << "\n" + "***************** CLING *****************\n" + "* Type C code and press enter to run it *\n" + "* Type .q to exit *\n" + "*****************************************\n"; + } } } // end namespace cling + + + + + + + + + + + + + -- GitLab