diff options
author | Fangrui Song <maskray@google.com> | 2018-09-06 20:26:54 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2018-09-06 20:26:54 +0000 |
commit | a3735821697d4c189c7f8acf97d9c316336b0fb2 (patch) | |
tree | 303cb6876c40381b287cb662482f1bb2b23acc0e /llvm/tools/llvm-dwp/llvm-dwp.cpp | |
parent | 2ba4d231d1d62c1afe9b123c326d60de7c542d10 (diff) | |
download | bcm5719-llvm-a3735821697d4c189c7f8acf97d9c316336b0fb2.tar.gz bcm5719-llvm-a3735821697d4c189c7f8acf97d9c316336b0fb2.zip |
Reland rL341509: "[llvm-dwp] Use buffer_stream if output file is not seekable (e.g. "-")"
It caused ambiguity between llvm::cl::Optional and llvm::Optional, which
has been fixed by dropping `using namespace cl;` in favor of explicit
cl:: qualified names.
llvm-svn: 341586
Diffstat (limited to 'llvm/tools/llvm-dwp/llvm-dwp.cpp')
-rw-r--r-- | llvm/tools/llvm-dwp/llvm-dwp.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index 176c470dd02..8a0744cf1e0 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -697,13 +697,21 @@ int main(int argc, char **argv) { // Create the output file. std::error_code EC; raw_fd_ostream OutFile(OutputFilename, EC, sys::fs::F_None); + Optional<buffer_ostream> BOS; + raw_pwrite_stream *OS; if (EC) return error(Twine(OutputFilename) + ": " + EC.message(), Context); + if (OutFile.supportsSeeking()) { + OS = &OutFile; + } else { + BOS.emplace(OutFile); + OS = BOS.getPointer(); + } MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags(); std::unique_ptr<MCStreamer> MS(TheTarget->createMCObjectStreamer( TheTriple, MC, std::unique_ptr<MCAsmBackend>(MAB), - MAB->createObjectWriter(OutFile), std::unique_ptr<MCCodeEmitter>(MCE), + MAB->createObjectWriter(*OS), std::unique_ptr<MCCodeEmitter>(MCE), *MSTI, MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible, /*DWARFMustBeAtTheEnd*/ false)); if (!MS) |