From: Daniel Dunbar Date: Sat, 21 Mar 2009 00:40:53 +0000 (+0000) Subject: Driver: Give Compilation::Execute total control over the Driver result X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af96def468042cfbed55a4cc12b1bb917ead4f33;p=clang Driver: Give Compilation::Execute total control over the Driver result code; and don't return an error code when -### is present, even if errors occur. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67425 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index 2a91842884..7a52498364 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -109,6 +109,8 @@ public: const OptTable &getOpts() const { return *Opts; } + const Diagnostic &getDiags() const { return Diags; } + /// @} /// @name Primary Functionality /// @{ diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index 48796afd82..a2fc9212a5 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -160,6 +160,10 @@ int Compilation::Execute() const { return 0; } + // If there were errors building the compilation, quit now. + if (getDriver().getDiags().getNumErrors()) + return 1; + int Res = ExecuteJob(Jobs); // Remove temp files. diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index 865b57c5ab..b227761197 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -87,15 +87,11 @@ int main(int argc, const char **argv) { llvm::OwningPtr C(TheDriver->BuildCompilation(argc, argv)); - // If there were errors building the compilation, quit now. - if (Diags.getNumErrors()) - return 1; - if (!C.get()) - return 0; - - int res = C->Execute(); + int Res = 0; + if (C.get()) + Res = C->Execute(); llvm::llvm_shutdown(); - return res; + return Res; }