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;
|
||||
|
||||
///\brief Processes the invocation options.
|
||||
///
|
||||
void handleFrontendOptions();
|
||||
|
||||
///\brief Worker function, building block for interpreter's public
|
||||
/// interfaces.
|
||||
///
|
||||
@ -346,7 +342,7 @@ namespace cling {
|
||||
///
|
||||
///\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.
|
||||
///
|
||||
|
@ -169,6 +169,20 @@ namespace cling {
|
||||
|
||||
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,
|
||||
const char* llvmdir /*= 0*/, bool noRuntime,
|
||||
const Interpreter* parentInterp) :
|
||||
@ -177,6 +191,9 @@ namespace cling {
|
||||
m_PrintDebug(false), m_DynamicLookupDeclared(false),
|
||||
m_DynamicLookupEnabled(false), m_RawInputEnabled(false) {
|
||||
|
||||
if (handleSimpleOptions(m_Opts))
|
||||
return;
|
||||
|
||||
m_LLVMContext.reset(new llvm::LLVMContext);
|
||||
m_DyLibManager.reset(new DynamicLibraryManager(getOptions()));
|
||||
m_IncrParser.reset(new IncrementalParser(this, llvmdir));
|
||||
@ -216,8 +233,6 @@ namespace cling {
|
||||
return;
|
||||
}
|
||||
|
||||
handleFrontendOptions();
|
||||
|
||||
llvm::SmallVector<llvm::StringRef, 6> Syms;
|
||||
Initialize(noRuntime, isInSyntaxOnlyMode(), Syms);
|
||||
|
||||
@ -317,19 +332,6 @@ namespace cling {
|
||||
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,
|
||||
llvm::SmallVectorImpl<llvm::StringRef>& Globals) {
|
||||
llvm::SmallString<1024> Buf;
|
||||
|
@ -79,12 +79,15 @@ int main( int argc, char **argv ) {
|
||||
cling::Interpreter interp(argc, argv);
|
||||
|
||||
if (!interp.isValid()) {
|
||||
const cling::InvocationOptions& Opts = interp.getOptions();
|
||||
if (Opts.Help || Opts.ShowVersion)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
unsigned ErrsReported = 0;
|
||||
if (clang::CompilerInstance* CI = interp.getCIOrNull()) {
|
||||
// If output requested and execution succeeded let the DiagnosticsEngine
|
||||
// determine the result code
|
||||
if (interp.getOptions().CompilerOpts.HasOutput &&
|
||||
ExecuteCompilerInvocation(CI))
|
||||
if (Opts.CompilerOpts.HasOutput && ExecuteCompilerInvocation(CI))
|
||||
return checkDiagErrors(CI);
|
||||
|
||||
checkDiagErrors(CI, &ErrsReported);
|
||||
@ -97,10 +100,6 @@ int main( int argc, char **argv ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (interp.getOptions().Help || interp.getOptions().ShowVersion)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
|
||||
interp.AddIncludePath(".");
|
||||
|
||||
for (size_t I = 0, N = interp.getOptions().LibsToLoad.size(); I < N; ++I) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user