From dc516f10b5fa8fa7bf270eda97950d6e714956d3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 14 May 2021 15:21:41 -0700 Subject: Support --symbolmap and --symbolmap=FOO in wasm-opt (#3885) wasm-as supports --symbolmap=FOO as an argument. We got a request to support the same in wasm-opt. wasm-opt does have --print-function-map which does the same, but as a pass. To unify them, use the new pass arg sugar from #3882 which allows us to add a --symbolmap pass whose argument can be set as --symbolmap=FOO. That perfectly matches the wasm-as notation. For now, keep the old --print-function-map notation as well, to not break emscripten. After we remove it there we can remove it here. --- src/support/file.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/support/file.cpp') 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 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; }()) {} -- cgit v1.2.3