From: Nick Desaulniers Date: Mon, 15 Oct 2018 17:39:00 +0000 (+0000) Subject: Revert 344389 "Revert r344375 "[Driver] check for exit code from SIGPIPE"" X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d0df31bed0a03b2e0e36ae25139824430585bf3;p=platform%2Fupstream%2Fllvm.git Revert 344389 "Revert r344375 "[Driver] check for exit code from SIGPIPE"" Summary: Add preprocessor guards for UNIX. This reverts commit r344389. Reviewers: rnk, majnemer, jfb Reviewed By: rnk Subscribers: cfe-commits, pirama, srhines Differential Revision: https://reviews.llvm.org/D53210 llvm-svn: 344536 --- diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 73639f3..6b927c1 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -81,6 +81,7 @@ #include #if LLVM_ON_UNIX #include // getpid +#include // EX_IOERR #endif using namespace clang::driver; @@ -1388,8 +1389,9 @@ int Driver::ExecuteCompilation( // Otherwise, remove result files and print extra information about abnormal // failures. + int Res = 0; for (const auto &CmdPair : FailingCommands) { - int Res = CmdPair.first; + int CommandRes = CmdPair.first; const Command *FailingCommand = CmdPair.second; // Remove result files if we're not saving temps. @@ -1398,10 +1400,19 @@ int Driver::ExecuteCompilation( C.CleanupFileMap(C.getResultFiles(), JA, true); // Failure result files are valid unless we crashed. - if (Res < 0) + if (CommandRes < 0) C.CleanupFileMap(C.getFailureResultFiles(), JA, true); } +#if LLVM_ON_UNIX + // llvm/lib/Support/Unix/Signals.inc will exit with a special return code + // for SIGPIPE. Do not print diagnostics for this case. + if (CommandRes == EX_IOERR) { + Res = CommandRes; + continue; + } +#endif + // Print extra information about abnormal failures, if possible. // // This is ad-hoc, but we don't want to be excessively noisy. If the result @@ -1411,17 +1422,17 @@ int Driver::ExecuteCompilation( // diagnostics, so always print the diagnostic there. const Tool &FailingTool = FailingCommand->getCreator(); - if (!FailingCommand->getCreator().hasGoodDiagnostics() || Res != 1) { + if (!FailingCommand->getCreator().hasGoodDiagnostics() || CommandRes != 1) { // FIXME: See FIXME above regarding result code interpretation. - if (Res < 0) + if (CommandRes < 0) Diag(clang::diag::err_drv_command_signalled) << FailingTool.getShortName(); else - Diag(clang::diag::err_drv_command_failed) << FailingTool.getShortName() - << Res; + Diag(clang::diag::err_drv_command_failed) + << FailingTool.getShortName() << CommandRes; } } - return 0; + return Res; } void Driver::PrintHelp(bool ShowHidden) const {