Tell which language is enabled (ROOT-7090).

This commit is contained in:
Axel Naumann 2015-02-21 23:09:18 +01:00 committed by sftnight
parent e582b93a16
commit faf2b44a0d
2 changed files with 43 additions and 10 deletions

View File

@ -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();

View File

@ -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