Early out Interpreter initialization when invoked via '-v' or '-version'.
This commit is contained in:
parent
14437862ef
commit
8aa8395cd6
@ -187,10 +187,6 @@ namespace cling {
|
|||||||
///
|
///
|
||||||
mutable std::vector<ClangInternalState*> m_StoredStates;
|
mutable std::vector<ClangInternalState*> m_StoredStates;
|
||||||
|
|
||||||
///\brief Processes the invocation options.
|
|
||||||
///
|
|
||||||
void handleFrontendOptions();
|
|
||||||
|
|
||||||
///\brief Worker function, building block for interpreter's public
|
///\brief Worker function, building block for interpreter's public
|
||||||
/// interfaces.
|
/// interfaces.
|
||||||
///
|
///
|
||||||
@ -346,7 +342,7 @@ namespace cling {
|
|||||||
///
|
///
|
||||||
///\returns The current svn revision (svn Id).
|
///\returns The current svn revision (svn Id).
|
||||||
///
|
///
|
||||||
const char* getVersion() const;
|
static const char* getVersion();
|
||||||
|
|
||||||
///\brief Creates unique name that can be used for various aims.
|
///\brief Creates unique name that can be used for various aims.
|
||||||
///
|
///
|
||||||
|
@ -169,6 +169,20 @@ namespace cling {
|
|||||||
|
|
||||||
namespace internal { void symbol_requester(); }
|
namespace internal { void symbol_requester(); }
|
||||||
|
|
||||||
|
const char* Interpreter::getVersion() {
|
||||||
|
return ClingStringify(CLING_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool handleSimpleOptions(const InvocationOptions& Opts) {
|
||||||
|
if (Opts.ShowVersion) {
|
||||||
|
cling::log() << Interpreter::getVersion() << '\n';
|
||||||
|
}
|
||||||
|
if (Opts.Help) {
|
||||||
|
Opts.PrintHelp();
|
||||||
|
}
|
||||||
|
return Opts.ShowVersion || Opts.Help;
|
||||||
|
}
|
||||||
|
|
||||||
Interpreter::Interpreter(int argc, const char* const *argv,
|
Interpreter::Interpreter(int argc, const char* const *argv,
|
||||||
const char* llvmdir /*= 0*/, bool noRuntime,
|
const char* llvmdir /*= 0*/, bool noRuntime,
|
||||||
const Interpreter* parentInterp) :
|
const Interpreter* parentInterp) :
|
||||||
@ -177,6 +191,9 @@ namespace cling {
|
|||||||
m_PrintDebug(false), m_DynamicLookupDeclared(false),
|
m_PrintDebug(false), m_DynamicLookupDeclared(false),
|
||||||
m_DynamicLookupEnabled(false), m_RawInputEnabled(false) {
|
m_DynamicLookupEnabled(false), m_RawInputEnabled(false) {
|
||||||
|
|
||||||
|
if (handleSimpleOptions(m_Opts))
|
||||||
|
return;
|
||||||
|
|
||||||
m_LLVMContext.reset(new llvm::LLVMContext);
|
m_LLVMContext.reset(new llvm::LLVMContext);
|
||||||
m_DyLibManager.reset(new DynamicLibraryManager(getOptions()));
|
m_DyLibManager.reset(new DynamicLibraryManager(getOptions()));
|
||||||
m_IncrParser.reset(new IncrementalParser(this, llvmdir));
|
m_IncrParser.reset(new IncrementalParser(this, llvmdir));
|
||||||
@ -216,8 +233,6 @@ namespace cling {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFrontendOptions();
|
|
||||||
|
|
||||||
llvm::SmallVector<llvm::StringRef, 6> Syms;
|
llvm::SmallVector<llvm::StringRef, 6> Syms;
|
||||||
Initialize(noRuntime, isInSyntaxOnlyMode(), Syms);
|
Initialize(noRuntime, isInSyntaxOnlyMode(), Syms);
|
||||||
|
|
||||||
@ -317,19 +332,6 @@ namespace cling {
|
|||||||
m_IncrParser.reset(0);
|
m_IncrParser.reset(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Interpreter::getVersion() const {
|
|
||||||
return ClingStringify(CLING_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Interpreter::handleFrontendOptions() {
|
|
||||||
if (m_Opts.ShowVersion) {
|
|
||||||
cling::log() << getVersion() << '\n';
|
|
||||||
}
|
|
||||||
if (m_Opts.Help) {
|
|
||||||
m_Opts.PrintHelp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Transaction* Interpreter::Initialize(bool NoRuntime, bool SyntaxOnly,
|
Transaction* Interpreter::Initialize(bool NoRuntime, bool SyntaxOnly,
|
||||||
llvm::SmallVectorImpl<llvm::StringRef>& Globals) {
|
llvm::SmallVectorImpl<llvm::StringRef>& Globals) {
|
||||||
llvm::SmallString<1024> Buf;
|
llvm::SmallString<1024> Buf;
|
||||||
|
@ -79,12 +79,15 @@ int main( int argc, char **argv ) {
|
|||||||
cling::Interpreter interp(argc, argv);
|
cling::Interpreter interp(argc, argv);
|
||||||
|
|
||||||
if (!interp.isValid()) {
|
if (!interp.isValid()) {
|
||||||
|
const cling::InvocationOptions& Opts = interp.getOptions();
|
||||||
|
if (Opts.Help || Opts.ShowVersion)
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
unsigned ErrsReported = 0;
|
unsigned ErrsReported = 0;
|
||||||
if (clang::CompilerInstance* CI = interp.getCIOrNull()) {
|
if (clang::CompilerInstance* CI = interp.getCIOrNull()) {
|
||||||
// If output requested and execution succeeded let the DiagnosticsEngine
|
// If output requested and execution succeeded let the DiagnosticsEngine
|
||||||
// determine the result code
|
// determine the result code
|
||||||
if (interp.getOptions().CompilerOpts.HasOutput &&
|
if (Opts.CompilerOpts.HasOutput && ExecuteCompilerInvocation(CI))
|
||||||
ExecuteCompilerInvocation(CI))
|
|
||||||
return checkDiagErrors(CI);
|
return checkDiagErrors(CI);
|
||||||
|
|
||||||
checkDiagErrors(CI, &ErrsReported);
|
checkDiagErrors(CI, &ErrsReported);
|
||||||
@ -97,10 +100,6 @@ int main( int argc, char **argv ) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interp.getOptions().Help || interp.getOptions().ShowVersion)
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
|
|
||||||
|
|
||||||
interp.AddIncludePath(".");
|
interp.AddIncludePath(".");
|
||||||
|
|
||||||
for (size_t I = 0, N = interp.getOptions().LibsToLoad.size(); I < N; ++I) {
|
for (size_t I = 0, N = interp.getOptions().LibsToLoad.size(); I < N; ++I) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user