This revision was automatically updated to reflect the committed changes. Closed by commit rL261774: Bail on compilation as soon as a job fails. (authored by jlebar).
Changed prior to commit: http://reviews.llvm.org/D17217?vs=47858&id=48976#toc Repository: rL LLVM http://reviews.llvm.org/D17217 Files: cfe/trunk/lib/Driver/Compilation.cpp cfe/trunk/test/Driver/output-file-cleanup.c Index: cfe/trunk/lib/Driver/Compilation.cpp =================================================================== --- cfe/trunk/lib/Driver/Compilation.cpp +++ cfe/trunk/lib/Driver/Compilation.cpp @@ -163,39 +163,17 @@ return ExecutionFailed ? 1 : Res; } -typedef SmallVectorImpl< std::pair<int, const Command *> > FailingCommandList; - -static bool ActionFailed(const Action *A, - const FailingCommandList &FailingCommands) { - - if (FailingCommands.empty()) - return false; - - for (FailingCommandList::const_iterator CI = FailingCommands.begin(), - CE = FailingCommands.end(); CI != CE; ++CI) - if (A == &(CI->second->getSource())) - return true; - - for (const Action *AI : A->inputs()) - if (ActionFailed(AI, FailingCommands)) - return true; - - return false; -} - -static bool InputsOk(const Command &C, - const FailingCommandList &FailingCommands) { - return !ActionFailed(&C.getSource(), FailingCommands); -} - -void Compilation::ExecuteJobs(const JobList &Jobs, - FailingCommandList &FailingCommands) const { +void Compilation::ExecuteJobs( + const JobList &Jobs, + SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) const { for (const auto &Job : Jobs) { - if (!InputsOk(Job, FailingCommands)) - continue; const Command *FailingCommand = nullptr; - if (int Res = ExecuteCommand(Job, FailingCommand)) + if (int Res = ExecuteCommand(Job, FailingCommand)) { FailingCommands.push_back(std::make_pair(Res, FailingCommand)); + // Bail as soon as one command fails, so we don't output duplicate error + // messages if we die on e.g. the same file. + return; + } } } Index: cfe/trunk/test/Driver/output-file-cleanup.c =================================================================== --- cfe/trunk/test/Driver/output-file-cleanup.c +++ cfe/trunk/test/Driver/output-file-cleanup.c @@ -38,14 +38,17 @@ // RUN: test -f %t1.s // RUN: test ! -f %t2.s +// When given multiple .c files to compile, clang compiles them in order until +// it hits an error, at which point it stops. +// // RUN: touch %t1.c // RUN: echo "invalid C code" > %t2.c // RUN: touch %t3.c // RUN: echo "invalid C code" > %t4.c // RUN: touch %t5.c // RUN: cd %T && not %clang -S %t1.c %t2.c %t3.c %t4.c %t5.c // RUN: test -f %t1.s // RUN: test ! -f %t2.s -// RUN: test -f %t3.s +// RUN: test ! -f %t3.s // RUN: test ! -f %t4.s -// RUN: test -f %t5.s +// RUN: test ! -f %t5.s
Index: cfe/trunk/lib/Driver/Compilation.cpp =================================================================== --- cfe/trunk/lib/Driver/Compilation.cpp +++ cfe/trunk/lib/Driver/Compilation.cpp @@ -163,39 +163,17 @@ return ExecutionFailed ? 1 : Res; } -typedef SmallVectorImpl< std::pair<int, const Command *> > FailingCommandList; - -static bool ActionFailed(const Action *A, - const FailingCommandList &FailingCommands) { - - if (FailingCommands.empty()) - return false; - - for (FailingCommandList::const_iterator CI = FailingCommands.begin(), - CE = FailingCommands.end(); CI != CE; ++CI) - if (A == &(CI->second->getSource())) - return true; - - for (const Action *AI : A->inputs()) - if (ActionFailed(AI, FailingCommands)) - return true; - - return false; -} - -static bool InputsOk(const Command &C, - const FailingCommandList &FailingCommands) { - return !ActionFailed(&C.getSource(), FailingCommands); -} - -void Compilation::ExecuteJobs(const JobList &Jobs, - FailingCommandList &FailingCommands) const { +void Compilation::ExecuteJobs( + const JobList &Jobs, + SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) const { for (const auto &Job : Jobs) { - if (!InputsOk(Job, FailingCommands)) - continue; const Command *FailingCommand = nullptr; - if (int Res = ExecuteCommand(Job, FailingCommand)) + if (int Res = ExecuteCommand(Job, FailingCommand)) { FailingCommands.push_back(std::make_pair(Res, FailingCommand)); + // Bail as soon as one command fails, so we don't output duplicate error + // messages if we die on e.g. the same file. + return; + } } } Index: cfe/trunk/test/Driver/output-file-cleanup.c =================================================================== --- cfe/trunk/test/Driver/output-file-cleanup.c +++ cfe/trunk/test/Driver/output-file-cleanup.c @@ -38,14 +38,17 @@ // RUN: test -f %t1.s // RUN: test ! -f %t2.s +// When given multiple .c files to compile, clang compiles them in order until +// it hits an error, at which point it stops. +// // RUN: touch %t1.c // RUN: echo "invalid C code" > %t2.c // RUN: touch %t3.c // RUN: echo "invalid C code" > %t4.c // RUN: touch %t5.c // RUN: cd %T && not %clang -S %t1.c %t2.c %t3.c %t4.c %t5.c // RUN: test -f %t1.s // RUN: test ! -f %t2.s -// RUN: test -f %t3.s +// RUN: test ! -f %t3.s // RUN: test ! -f %t4.s -// RUN: test -f %t5.s +// RUN: test ! -f %t5.s
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits