Skip to content
Prev Previous commit
Next Next commit
clang-format
  • Loading branch information
dschuff committed Apr 5, 2023
commit afc99149f82ea9e6015e96a9e1a607bd61749fd0
16 changes: 10 additions & 6 deletions src/support/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ template<> std::string do_read_stdin<std::string>::operator()() {
}

template<typename T>
T wasm::read_file(const std::filesystem::path& filename, Flags::BinaryOption binary) {
T wasm::read_file(const std::filesystem::path& filename,
Flags::BinaryOption binary) {
if (filename == "-") {
return do_read_stdin<T>{}();
}
Expand Down Expand Up @@ -96,11 +97,13 @@ std::string wasm::read_possible_response_file(const std::string& input) {
}

// Explicit instantiations for the explicit specializations.
template std::string wasm::read_file<>(const std::filesystem::path&, Flags::BinaryOption);
template std::string wasm::read_file<>(const std::filesystem::path&,
Flags::BinaryOption);
template std::vector<char> wasm::read_file<>(const std::filesystem::path&,
Flags::BinaryOption);

wasm::Output::Output(const std::filesystem::path& filename, Flags::BinaryOption binary)
wasm::Output::Output(const std::filesystem::path& filename,
Flags::BinaryOption binary)
: outfile(), out([this, filename, binary]() {
// Ensure a single return at the very end, to avoid clang-tidy warnings
// about the types of different returns here.
Expand All @@ -122,7 +125,8 @@ wasm::Output::Output(const std::filesystem::path& filename, Flags::BinaryOption
return buffer;
}()) {}

void wasm::copy_file(std::filesystem::path input, std::filesystem::path output) {
std::filesystem::copy_file(input, output, std::filesystem::copy_options::overwrite_existing);
void wasm::copy_file(std::filesystem::path input,
std::filesystem::path output) {
std::filesystem::copy_file(
input, output, std::filesystem::copy_options::overwrite_existing);
}

1 change: 0 additions & 1 deletion src/support/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Output {
// Copies a file to another file, overwriting if the fiel exists
void copy_file(std::filesystem::path input, std::filesystem::path output);


} // namespace wasm

#endif // wasm_support_file_h
9 changes: 6 additions & 3 deletions src/wasm-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ class ModuleReader : public ModuleIOBase {
std::filesystem::path sourceMapFilename = "");
// read text or binary, checking the contents for what it is. If `filename` is
// empty, read from stdin.
void
read(std::filesystem::path filename, Module& wasm, std::filesystem::path sourceMapFilename = "");
void read(std::filesystem::path filename,
Module& wasm,
std::filesystem::path sourceMapFilename = "");
// check whether a file is a wasm binary
bool isBinaryFile(std::filesystem::path filename);

Expand Down Expand Up @@ -100,7 +101,9 @@ class ModuleWriter : public ModuleIOBase {
ModuleWriter() { setDebugInfo(false); }

void setBinary(bool binary_) { binary = binary_; }
void setSymbolMap(std::filesystem::path symbolMap_) { symbolMap = symbolMap_; }
void setSymbolMap(std::filesystem::path symbolMap_) {
symbolMap = symbolMap_;
}
void setSourceMapFilename(std::filesystem::path sourceMapFilename_) {
sourceMapFilename = sourceMapFilename_;
}
Expand Down
3 changes: 2 additions & 1 deletion src/wasm/wasm-io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ void ModuleReader::read(std::filesystem::path filename,

// TODO: reading into a vector<char> then copying into a string is unnecessarily
// inefficient. It would be better to read just once into a stringstream.
void ModuleReader::readStdin(Module& wasm, std::filesystem::path sourceMapFilename) {
void ModuleReader::readStdin(Module& wasm,
std::filesystem::path sourceMapFilename) {
std::vector<char> input = read_stdin();
if (input.size() >= 4 && input[0] == '\0' && input[1] == 'a' &&
input[2] == 's' && input[3] == 'm') {
Expand Down