diff options
author | Chad Rosier <mcrosier@apple.com> | 2013-01-29 20:15:05 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2013-01-29 20:15:05 +0000 |
commit | a16355c31878403443f99077cc8df8318457faf5 (patch) | |
tree | a09155eff30a4a409d7ef68e7386524c1925af41 /tools/driver/driver.cpp | |
parent | d4f2c2e21addd8ed0a50b92f062d3229cde0506a (diff) |
[driver] Refactor the driver so that a failing commands doesn't prevent
subsequent commands from being executed.
The diagnostics generation isn't designed for this use case, so add a note to
fix this in the very near future. For now, just generated the diagnostics for
the first failing command.
Part of rdar://12984531
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173825 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/driver/driver.cpp')
-rw-r--r-- | tools/driver/driver.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index 81bc985cc6..7ccf57a242 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -466,21 +466,35 @@ int main(int argc_, const char **argv_) { OwningPtr<Compilation> C(TheDriver.BuildCompilation(argv)); int Res = 0; - const Command *FailingCommand = 0; + SmallVector<std::pair<int, const Command *>, 4> FailingCommands; if (C.get()) - Res = TheDriver.ExecuteCompilation(*C, FailingCommand); + Res = TheDriver.ExecuteCompilation(*C, FailingCommands); // Force a crash to test the diagnostics. if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) { Diags.Report(diag::err_drv_force_crash) << "FORCE_CLANG_DIAGNOSTICS_CRASH"; - Res = -1; + const Command *FailingCommand = 0; + FailingCommands.push_back(std::make_pair(-1, FailingCommand)); } - // 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. - // In these cases, generate additional diagnostic information if possible. - if (Res < 0 || Res == 70) - TheDriver.generateCompilationDiagnostics(*C, FailingCommand); + for (SmallVectorImpl< std::pair<int, const Command *> >::iterator it = + FailingCommands.begin(), ie = FailingCommands.end(); it != ie; ++it) { + int CommandRes = it->first; + const Command *FailingCommand = it->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. + // In these cases, generate additional diagnostic information if possible. + if (CommandRes < 0 || CommandRes == 70) { + TheDriver.generateCompilationDiagnostics(*C, FailingCommand); + + // FIXME: generateCompilationDiagnostics() needs to be tested when there + // are multiple failing commands. + break; + } + } // If any timers were active but haven't been destroyed yet, print their // results now. This happens in -disable-free mode. @@ -496,5 +510,7 @@ int main(int argc_, const char **argv_) { Res = 1; #endif + // If we have multiple failing commands, we return the result of the first + // failing command. return Res; } |