diff options
Diffstat (limited to 'src/support/file.cpp')
-rw-r--r-- | src/support/file.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/support/file.cpp b/src/support/file.cpp index 2a8426461..d17e3a338 100644 --- a/src/support/file.cpp +++ b/src/support/file.cpp @@ -88,11 +88,12 @@ template std::vector<char> wasm::read_file<>(const std::string&, wasm::Output::Output(const std::string& filename, Flags::BinaryOption binary) : outfile(), out([this, filename, binary]() { - if (filename == "-") { - return std::cout.rdbuf(); - } + // Ensure a single return at the very end, to avoid clang-tidy warnings + // about the types of different returns here. std::streambuf* buffer; - if (filename.size()) { + if (filename == "-" || filename.empty()) { + buffer = std::cout.rdbuf(); + } else { BYN_TRACE("Opening '" << filename << "'\n"); auto flags = std::ofstream::out | std::ofstream::trunc; if (binary == Flags::Binary) { @@ -104,8 +105,6 @@ wasm::Output::Output(const std::string& filename, Flags::BinaryOption binary) exit(EXIT_FAILURE); } buffer = outfile.rdbuf(); - } else { - buffer = std::cout.rdbuf(); } return buffer; }()) {} |