diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2017-05-11 08:00:33 +0000 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2017-05-11 08:00:33 +0000 |
commit | c5cc230587a01130ffe8a5a4b9e2779c25222984 (patch) | |
tree | 5250516f995dd187ac062c84bbe7f5084072504f /clang/tools | |
parent | c7b5977bb1bd6bdde311d5fc71ee3bbc1e14cdab (diff) | |
download | bcm5719-llvm-c5cc230587a01130ffe8a5a4b9e2779c25222984.tar.gz bcm5719-llvm-c5cc230587a01130ffe8a5a4b9e2779c25222984.zip |
Driver must return non-zero code on errors in command line
Now if clang driver is given wrong arguments, in some cases it
continues execution and returns zero code. This change fixes this
behavior.
The fix revealed some errors in clang test set.
File test/Driver/gfortran.f90 added in r118203 checks forwarding
gfortran flags to GCC. Now driver reports error on this file, because
the option -working-directory implemented in clang differs from the
option with the same name implemented in gfortran, in clang the option
requires argument, in gfortran does not.
In the file test/Driver/arm-darwin-builtin.c clang is called with
options -fbuiltin-strcat and -fbuiltin-strcpy. These option were removed
in r191435 and now clang reports error on this test.
File arm-default-build-attributes.s uses option -verify, which is not
supported by driver, it is cc1 option.
Similarly, the file split-debug.h uses options -fmodules-embed-all-files
and -fmodule-format=obj, which are not supported by driver.
Other revealed errors are mainly mistypes.
Differential Revision: https://reviews.llvm.org/D33013
llvm-svn: 302775
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/driver/driver.cpp | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index 626d006ac0d..4bd3b228d0f 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -454,40 +454,41 @@ int main(int argc_, const char **argv_) { SetBackdoorDriverOutputsFromEnvVars(TheDriver); std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(argv)); - int Res = 0; - SmallVector<std::pair<int, const Command *>, 4> FailingCommands; - if (C.get()) + int Res = 1; + if (C.get()) { + SmallVector<std::pair<int, const Command *>, 4> FailingCommands; Res = TheDriver.ExecuteCompilation(*C, FailingCommands); - // Force a crash to test the diagnostics. - if (TheDriver.GenReproducer) { - Diags.Report(diag::err_drv_force_crash) + // Force a crash to test the diagnostics. + if (TheDriver.GenReproducer) { + Diags.Report(diag::err_drv_force_crash) << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"); - // Pretend that every command failed. - FailingCommands.clear(); - for (const auto &J : C->getJobs()) - if (const Command *C = dyn_cast<Command>(&J)) - FailingCommands.push_back(std::make_pair(-1, C)); - } + // Pretend that every command failed. + FailingCommands.clear(); + for (const auto &J : C->getJobs()) + if (const Command *C = dyn_cast<Command>(&J)) + FailingCommands.push_back(std::make_pair(-1, C)); + } - for (const auto &P : FailingCommands) { - int CommandRes = P.first; - const Command *FailingCommand = P.second; - if (!Res) - Res = CommandRes; - - // If result status is < 0, then the driver command signalled an error. - // If result status is 70, then the driver command reported a fatal error. - // On Windows, abort will return an exit code of 3. In these cases, - // generate additional diagnostic information if possible. - bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70; + for (const auto &P : FailingCommands) { + int CommandRes = P.first; + const Command *FailingCommand = P.second; + if (!Res) + Res = CommandRes; + + // If result status is < 0, then the driver command signalled an error. + // If result status is 70, then the driver command reported a fatal error. + // On Windows, abort will return an exit code of 3. In these cases, + // generate additional diagnostic information if possible. + bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70; #ifdef LLVM_ON_WIN32 - DiagnoseCrash |= CommandRes == 3; + DiagnoseCrash |= CommandRes == 3; #endif - if (DiagnoseCrash) { - TheDriver.generateCompilationDiagnostics(*C, *FailingCommand); - break; + if (DiagnoseCrash) { + TheDriver.generateCompilationDiagnostics(*C, *FailingCommand); + break; + } } } |