From db9124f1de0478dcac525009b6f1589b44a7edd8 Mon Sep 17 00:00:00 2001
From: Alon Zakai <azakai@google.com>
Date: Fri, 26 Apr 2019 16:59:41 -0700
Subject: Apply format changes from #2048 (#2059)

Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
---
 src/wasm/wasm-io.cpp | 47 +++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 18 deletions(-)

(limited to 'src/wasm/wasm-io.cpp')

diff --git a/src/wasm/wasm-io.cpp b/src/wasm/wasm-io.cpp
index 057798d2e..1bdb76d5f 100644
--- a/src/wasm/wasm-io.cpp
+++ b/src/wasm/wasm-io.cpp
@@ -25,8 +25,8 @@
 //
 
 #include "wasm-io.h"
-#include "wasm-s-parser.h"
 #include "wasm-binary.h"
+#include "wasm-s-parser.h"
 
 namespace wasm {
 
@@ -34,17 +34,20 @@ static void readTextData(std::string& input, Module& wasm) {
   SExpressionParser parser(const_cast<char*>(input.c_str()));
   Element& root = *parser.root;
   SExpressionWasmBuilder builder(wasm, *root[0]);
-
 }
 
 void ModuleReader::readText(std::string filename, Module& wasm) {
-  if (debug) std::cerr << "reading text from " << filename << "\n";
-  auto input(read_file<std::string>(filename, Flags::Text, debug ? Flags::Debug : Flags::Release));
+  if (debug)
+    std::cerr << "reading text from " << filename << "\n";
+  auto input(read_file<std::string>(
+    filename, Flags::Text, debug ? Flags::Debug : Flags::Release));
   readTextData(input, wasm);
 }
 
-static void readBinaryData(std::vector<char>& input, Module& wasm,
-                           std::string sourceMapFilename, bool debug) {
+static void readBinaryData(std::vector<char>& input,
+                           Module& wasm,
+                           std::string sourceMapFilename,
+                           bool debug) {
   std::unique_ptr<std::ifstream> sourceMapStream;
   WasmBinaryBuilder parser(wasm, input, debug);
   if (sourceMapFilename.size()) {
@@ -58,10 +61,13 @@ static void readBinaryData(std::vector<char>& input, Module& wasm,
   }
 }
 
-void ModuleReader::readBinary(std::string filename, Module& wasm,
+void ModuleReader::readBinary(std::string filename,
+                              Module& wasm,
                               std::string sourceMapFilename) {
-  if (debug) std::cerr << "reading binary from " << filename << "\n";
-  auto input(read_file<std::vector<char>>(filename, Flags::Binary, debug ? Flags::Debug : Flags::Release));
+  if (debug)
+    std::cerr << "reading binary from " << filename << "\n";
+  auto input(read_file<std::vector<char>>(
+    filename, Flags::Binary, debug ? Flags::Debug : Flags::Release));
   readBinaryData(input, wasm, sourceMapFilename, debug);
 }
 
@@ -69,13 +75,15 @@ bool ModuleReader::isBinaryFile(std::string filename) {
   std::ifstream infile;
   std::ios_base::openmode flags = std::ifstream::in | std::ifstream::binary;
   infile.open(filename, flags);
-  char buffer[4] = { 1, 2, 3, 4 };
+  char buffer[4] = {1, 2, 3, 4};
   infile.read(buffer, 4);
   infile.close();
-  return buffer[0] == '\0' && buffer[1] == 'a' && buffer[2] == 's' && buffer[3] == 'm';
+  return buffer[0] == '\0' && buffer[1] == 'a' && buffer[2] == 's' &&
+         buffer[3] == 'm';
 }
 
-void ModuleReader::read(std::string filename, Module& wasm,
+void ModuleReader::read(std::string filename,
+                        Module& wasm,
                         std::string sourceMapFilename) {
   // empty filename means read from stdin
   if (!filename.size()) {
@@ -87,7 +95,8 @@ void ModuleReader::read(std::string filename, Module& wasm,
   } else {
     // default to text
     if (sourceMapFilename.size()) {
-      std::cerr << "Binaryen ModuleReader::read() - source map filename provided, but file appears to not be binary\n";
+      std::cerr << "Binaryen ModuleReader::read() - source map filename "
+                   "provided, but file appears to not be binary\n";
     }
     readText(filename, wasm);
   }
@@ -109,13 +118,13 @@ void ModuleReader::readStdin(Module& wasm, std::string sourceMapFilename) {
   }
 }
 
-
 void ModuleWriter::writeText(Module& wasm, Output& output) {
   WasmPrinter::printModule(&wasm, output.getStream());
 }
 
 void ModuleWriter::writeText(Module& wasm, std::string filename) {
-  if (debug) std::cerr << "writing text to " << filename << "\n";
+  if (debug)
+    std::cerr << "writing text to " << filename << "\n";
   Output output(filename, Flags::Text, debug ? Flags::Debug : Flags::Release);
   writeText(wasm, output);
 }
@@ -131,7 +140,8 @@ void ModuleWriter::writeBinary(Module& wasm, Output& output) {
     sourceMapStream->open(sourceMapFilename);
     writer.setSourceMap(sourceMapStream.get(), sourceMapUrl);
   }
-  if (symbolMap.size() > 0) writer.setSymbolMap(symbolMap);
+  if (symbolMap.size() > 0)
+    writer.setSymbolMap(symbolMap);
   writer.write();
   buffer.writeTo(output);
   if (sourceMapStream) {
@@ -140,7 +150,8 @@ void ModuleWriter::writeBinary(Module& wasm, Output& output) {
 }
 
 void ModuleWriter::writeBinary(Module& wasm, std::string filename) {
-  if (debug) std::cerr << "writing binary to " << filename << "\n";
+  if (debug)
+    std::cerr << "writing binary to " << filename << "\n";
   Output output(filename, Flags::Binary, debug ? Flags::Debug : Flags::Release);
   writeBinary(wasm, output);
 }
@@ -161,4 +172,4 @@ void ModuleWriter::write(Module& wasm, std::string filename) {
   }
 }
 
-}
+} // namespace wasm
-- 
cgit v1.2.3