summaryrefslogtreecommitdiff
path: root/src/support/file.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-05-14 15:21:41 -0700
committerGitHub <noreply@github.com>2021-05-14 15:21:41 -0700
commitdc516f10b5fa8fa7bf270eda97950d6e714956d3 (patch)
tree73602595dacabcc72d2342f7ffd4d0d6cf8f60f3 /src/support/file.cpp
parentf59174c1cf526d7e9fe5d4ba74ab0370f40a1856 (diff)
downloadbinaryen-dc516f10b5fa8fa7bf270eda97950d6e714956d3.tar.gz
binaryen-dc516f10b5fa8fa7bf270eda97950d6e714956d3.tar.bz2
binaryen-dc516f10b5fa8fa7bf270eda97950d6e714956d3.zip
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.
Diffstat (limited to 'src/support/file.cpp')
-rw-r--r--src/support/file.cpp11
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;
}()) {}