diff options
Diffstat (limited to 'llvm/tools/llvm-dwp/llvm-dwp.cpp')
| -rw-r--r-- | llvm/tools/llvm-dwp/llvm-dwp.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index d2d162d648c0..0a2c1c1ccc02 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/ToolOutputFile.h" +#include <optional> using namespace llvm; using namespace llvm::object; @@ -71,7 +72,10 @@ getDWOFilenames(StringRef ExecFilename) { if (!DWOCompDir.empty()) { SmallString<16> DWOPath(std::move(DWOName)); sys::fs::make_absolute(DWOCompDir, DWOPath); - DWOPaths.emplace_back(DWOPath.data(), DWOPath.size()); + if (!sys::fs::exists(DWOPath) && sys::fs::exists(DWOName)) + DWOPaths.push_back(std::move(DWOName)); + else + DWOPaths.emplace_back(DWOPath.data(), DWOPath.size()); } else { DWOPaths.push_back(std::move(DWOName)); } @@ -108,7 +112,13 @@ int main(int argc, char **argv) { for (const auto &ExecFilename : ExecFilenames) { auto DWOs = getDWOFilenames(ExecFilename); if (!DWOs) { - logAllUnhandledErrors(DWOs.takeError(), WithColor::error()); + logAllUnhandledErrors( + handleErrors(DWOs.takeError(), + [&](std::unique_ptr<ECError> EC) -> Error { + return createFileError(ExecFilename, + Error(std::move(EC))); + }), + WithColor::error()); return 1; } DWOFilenames.insert(DWOFilenames.end(), @@ -124,7 +134,13 @@ int main(int argc, char **argv) { auto ErrOrTriple = readTargetTriple(DWOFilenames.front()); if (!ErrOrTriple) { - logAllUnhandledErrors(ErrOrTriple.takeError(), WithColor::error()); + logAllUnhandledErrors( + handleErrors(ErrOrTriple.takeError(), + [&](std::unique_ptr<ECError> EC) -> Error { + return createFileError(DWOFilenames.front(), + Error(std::move(EC))); + }), + WithColor::error()); return 1; } @@ -172,7 +188,7 @@ int main(int argc, char **argv) { // Create the output file. std::error_code EC; ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None); - Optional<buffer_ostream> BOS; + std::optional<buffer_ostream> BOS; raw_pwrite_stream *OS; if (EC) return error(Twine(OutputFilename) + ": " + EC.message(), Context); @@ -180,7 +196,7 @@ int main(int argc, char **argv) { OS = &OutFile.os(); } else { BOS.emplace(OutFile.os()); - OS = BOS.getPointer(); + OS = &*BOS; } std::unique_ptr<MCStreamer> MS(TheTarget->createMCObjectStreamer( |
