|
19 | 19 | #include <llvm/Support/CommandLine.h>
|
20 | 20 | #include <llvm/Support/FileSystem.h>
|
21 | 21 | #include <llvm/Support/Path.h>
|
| 22 | +#include <llvm/Support/Program.h> |
22 | 23 | #include <llvm/Support/Signals.h>
|
23 | 24 | #include <llvm/Support/ThreadPool.h>
|
24 | 25 | #include <atomic>
|
@@ -271,15 +272,27 @@ handleFile(
|
271 | 272 | if(options_.badOption.getValue())
|
272 | 273 | {
|
273 | 274 | // Write the .bad.xml file
|
274 |
| - path::replace_extension(outputPath, "bad.xml"); |
275 |
| - std::error_code ec; |
276 |
| - llvm::raw_fd_ostream os(outputPath, ec, llvm::sys::fs::OF_None); |
277 |
| - if(ec) |
| 275 | + auto bad = outputPath; |
| 276 | + path::replace_extension(bad, "bad.xml"); |
278 | 277 | {
|
279 |
| - results_.numberOfErrors++; |
280 |
| - return makeError("raw_fd_ostream returned ", ec); |
| 278 | + std::error_code ec; |
| 279 | + llvm::raw_fd_ostream os(bad, ec, llvm::sys::fs::OF_None); |
| 280 | + if (ec) { |
| 281 | + results_.numberOfErrors++; |
| 282 | + return makeError("raw_fd_ostream returned ", ec); |
| 283 | + } |
| 284 | + os << generatedXml; |
| 285 | + } |
| 286 | + |
| 287 | + auto diff = llvm::sys::findProgramByName("diff"); |
| 288 | + |
| 289 | + if (!diff.getError()) |
| 290 | + { |
| 291 | + path::replace_extension(bad, "xml"); |
| 292 | + std::array<llvm::StringRef, 5u> args { |
| 293 | + diff.get(), "-u", "--color", bad, outputPath }; |
| 294 | + llvm::sys::ExecuteAndWait(diff.get(), args); |
281 | 295 | }
|
282 |
| - os << generatedXml; |
283 | 296 |
|
284 | 297 | // Fix the path for the code that follows
|
285 | 298 | outputPath.pop_back_n(8);
|
|
0 commit comments