From e59cf9369004a521814222afbc05ae6b59446cd5 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin@gmail.com>
Date: Mon, 20 Dec 2021 19:35:01 -0800
Subject: Clang-format codebase (#1684)

This applies clang-format to the whole codebase.

I noticed we have .clang-format in wabt but the codebase is not very
well formatted. This kind of mass-formatting PR has fans and skeptics
because it can mess with `git blame`, but we did a similar thing in
Binaryen a few years ago (WebAssembly/binaryen#2048, which was merged in
WebAssembly/binaryen#2059) and it was not very confusing after all.
If we are ever going to format the codebase, I think it is easier to do
it in a single big PR than dozens of smaller PRs.

This is using the existing .clang-format file in this repo, which
follows the style of Chromium. If we think this does not suit the
current formatting style, we can potentially tweak .clang-format too.
For example, I noticed the current codebase puts many `case` statements
within a single line when they are short, but the current .clang-format
does not allow that.

This does not include files in src/prebuilt, because they are generated.

This also manually fixes some comment lines, because mechanically
applying clang-format to long inline comments can look weird.

I also added a clang-format check hook in the Github CI in #1683, which
I think can be less controversial, given that it only checks the diff.

---

After discussions, we ended up reverting many changes, especially
one-liner functions and switch-cases, which are too many to wrap in
`// clang-format off` and `// clang-format on`. I also considered fixing
`.clang-format` to allow those one-liners but it caused a larger churn
in other parts. So currently the codebase does not conform to
`.clang-format` 100%, but we decided it's fine.
---
 src/interp/binary-reader-interp.cc |  6 ++--
 src/interp/interp-inl.h            | 26 ++++++++-------
 src/interp/interp-math.h           | 16 ++++++----
 src/interp/interp-util.h           |  2 +-
 src/interp/interp-wasi.cc          | 47 ++++++++++++++-------------
 src/interp/interp-wasm-c-api.cc    | 20 ++++++------
 src/interp/interp.cc               | 37 ++++++++++------------
 src/interp/interp.h                | 19 ++++++-----
 src/interp/istream.cc              |  9 +++---
 src/interp/istream.h               | 65 ++++++++++++++++++++------------------
 10 files changed, 131 insertions(+), 116 deletions(-)

(limited to 'src/interp')

diff --git a/src/interp/binary-reader-interp.cc b/src/interp/binary-reader-interp.cc
index 699fdd20..cf4436f6 100644
--- a/src/interp/binary-reader-interp.cc
+++ b/src/interp/binary-reader-interp.cc
@@ -911,9 +911,9 @@ Result BinaryReaderInterp::OnSimdLoadLaneExpr(Opcode opcode,
 }
 
 Result BinaryReaderInterp::OnSimdStoreLaneExpr(Opcode opcode,
-                                              Address alignment_log2,
-                                              Address offset,
-                                              uint64_t value) {
+                                               Address alignment_log2,
+                                               Address offset,
+                                               uint64_t value) {
   CHECK_RESULT(validator_.OnSimdStoreLane(GetLocation(), opcode,
                                           GetAlignment(alignment_log2), value));
   istream_.Emit(opcode, kMemoryIndex0, offset, static_cast<u8>(value));
diff --git a/src/interp/interp-inl.h b/src/interp/interp-inl.h
index 2c452f02..1237d811 100644
--- a/src/interp/interp-inl.h
+++ b/src/interp/interp-inl.h
@@ -261,7 +261,7 @@ RefPtr<T>::RefPtr(const RefPtr<U>& other)
 
 template <typename T>
 template <typename U>
-RefPtr<T>& RefPtr<T>::operator=(const RefPtr<U>& other){
+RefPtr<T>& RefPtr<T>::operator=(const RefPtr<U>& other) {
   obj_ = other.obj_;
   store_ = other.store_;
   root_index_ = store_ ? store_->CopyRoot(other.root_index_) : 0;
@@ -366,7 +366,8 @@ template <> inline bool HasType<f32>(ValueType type) { return type == ValueType:
 template <> inline bool HasType<f64>(ValueType type) { return type == ValueType::F64; }
 template <> inline bool HasType<Ref>(ValueType type) { return IsReference(type); }
 
-template <typename T> void RequireType(ValueType type) {
+template <typename T>
+void RequireType(ValueType type) {
   assert(HasType<T>(type));
 }
 
@@ -659,10 +660,8 @@ inline Memory::Ptr Memory::New(interp::Store& store, MemoryType type) {
 
 inline bool Memory::IsValidAccess(u64 offset, u64 addend, u64 size) const {
   // FIXME: make this faster.
-  return offset <= data_.size() &&
-         addend <= data_.size() &&
-         size <= data_.size() &&
-         offset + addend + size <= data_.size();
+  return offset <= data_.size() && addend <= data_.size() &&
+         size <= data_.size() && offset + addend + size <= data_.size();
 }
 
 inline bool Memory::IsValidAtomicAccess(u64 offset,
@@ -677,7 +676,8 @@ Result Memory::Load(u64 offset, u64 addend, T* out) const {
   if (!IsValidAccess(offset, addend, sizeof(T))) {
     return Result::Error;
   }
-  wabt::MemcpyEndianAware(out, data_.data(), sizeof(T), data_.size(), 0, offset + addend, sizeof(T));
+  wabt::MemcpyEndianAware(out, data_.data(), sizeof(T), data_.size(), 0,
+                          offset + addend, sizeof(T));
   return Result::Ok;
 }
 
@@ -685,7 +685,8 @@ template <typename T>
 T WABT_VECTORCALL Memory::UnsafeLoad(u64 offset, u64 addend) const {
   assert(IsValidAccess(offset, addend, sizeof(T)));
   T val;
-  wabt::MemcpyEndianAware(&val, data_.data(), sizeof(T), data_.size(), 0, offset + addend, sizeof(T));
+  wabt::MemcpyEndianAware(&val, data_.data(), sizeof(T), data_.size(), 0,
+                          offset + addend, sizeof(T));
   return val;
 }
 
@@ -694,7 +695,8 @@ Result WABT_VECTORCALL Memory::Store(u64 offset, u64 addend, T val) {
   if (!IsValidAccess(offset, addend, sizeof(T))) {
     return Result::Error;
   }
-  wabt::MemcpyEndianAware(data_.data(), &val, data_.size(), sizeof(T), offset + addend, 0, sizeof(T));
+  wabt::MemcpyEndianAware(data_.data(), &val, data_.size(), sizeof(T),
+                          offset + addend, 0, sizeof(T));
   return Result::Ok;
 }
 
@@ -703,7 +705,8 @@ Result Memory::AtomicLoad(u64 offset, u64 addend, T* out) const {
   if (!IsValidAtomicAccess(offset, addend, sizeof(T))) {
     return Result::Error;
   }
-  wabt::MemcpyEndianAware(out, data_.data(), sizeof(T), data_.size(), 0, offset + addend, sizeof(T));
+  wabt::MemcpyEndianAware(out, data_.data(), sizeof(T), data_.size(), 0,
+                          offset + addend, sizeof(T));
   return Result::Ok;
 }
 
@@ -712,7 +715,8 @@ Result Memory::AtomicStore(u64 offset, u64 addend, T val) {
   if (!IsValidAtomicAccess(offset, addend, sizeof(T))) {
     return Result::Error;
   }
-  wabt::MemcpyEndianAware(data_.data(), &val, data_.size(), sizeof(T), offset + addend, 0, sizeof(T));
+  wabt::MemcpyEndianAware(data_.data(), &val, data_.size(), sizeof(T),
+                          offset + addend, 0, sizeof(T));
   return Result::Ok;
 }
 
diff --git a/src/interp/interp-math.h b/src/interp/interp-math.h
index 25716b27..444a5ee5 100644
--- a/src/interp/interp-math.h
+++ b/src/interp/interp-math.h
@@ -211,17 +211,19 @@ inline f64 WABT_VECTORCALL FloatAbs(f64 val) {
 template <>
 inline f32 WABT_VECTORCALL FloatCopysign(f32 lhs, f32 rhs) {
   return _mm_cvtss_f32(
-    _mm_or_ps(
-      _mm_and_ps(_mm_set1_ps(lhs), _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff))),
-      _mm_and_ps(_mm_set1_ps(rhs), _mm_castsi128_ps(_mm_set1_epi32(0x80000000)))));
+      _mm_or_ps(_mm_and_ps(_mm_set1_ps(lhs),
+                           _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff))),
+                _mm_and_ps(_mm_set1_ps(rhs),
+                           _mm_castsi128_ps(_mm_set1_epi32(0x80000000)))));
 }
 
 template <>
 inline f64 WABT_VECTORCALL FloatCopysign(f64 lhs, f64 rhs) {
-  return _mm_cvtsd_f64(
-    _mm_or_pd(
-      _mm_and_pd(_mm_set1_pd(lhs), _mm_castsi128_pd(_mm_set1_epi64x(0x7fffffffffffffffull))),
-      _mm_and_pd(_mm_set1_pd(rhs), _mm_castsi128_pd(_mm_set1_epi64x(0x8000000000000000ull)))));
+  return _mm_cvtsd_f64(_mm_or_pd(
+      _mm_and_pd(_mm_set1_pd(lhs),
+                 _mm_castsi128_pd(_mm_set1_epi64x(0x7fffffffffffffffull))),
+      _mm_and_pd(_mm_set1_pd(rhs),
+                 _mm_castsi128_pd(_mm_set1_epi64x(0x8000000000000000ull)))));
 }
 
 #else
diff --git a/src/interp/interp-util.h b/src/interp/interp-util.h
index d05b34de..bc94abc2 100644
--- a/src/interp/interp-util.h
+++ b/src/interp/interp-util.h
@@ -47,4 +47,4 @@ void WriteCall(Stream* stream,
 }  // namespace interp
 }  // namespace wabt
 
-#endif // WABT_INTERP_UTIL_H_
+#endif  // WABT_INTERP_UTIL_H_
diff --git a/src/interp/interp-wasi.cc b/src/interp/interp-wasi.cc
index 15d71250..61b6f71d 100644
--- a/src/interp/interp-wasi.cc
+++ b/src/interp/interp-wasi.cc
@@ -92,13 +92,13 @@ typedef struct __wasi_fdstat_t {
 static_assert(sizeof(__wasi_fdstat_t) == 24, "witx calculated size");
 static_assert(alignof(__wasi_fdstat_t) == 8, "witx calculated align");
 static_assert(offsetof(__wasi_fdstat_t, fs_filetype) == 0,
-               "witx calculated offset");
+              "witx calculated offset");
 static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2,
-               "witx calculated offset");
+              "witx calculated offset");
 static_assert(offsetof(__wasi_fdstat_t, fs_rights_base) == 8,
-               "witx calculated offset");
+              "witx calculated offset");
 static_assert(offsetof(__wasi_fdstat_t, fs_rights_inheriting) == 16,
-               "witx calculated offset");
+              "witx calculated offset");
 
 struct __wasi_iovec_t {
   __wasi_ptr_t buf;
@@ -141,17 +141,17 @@ static_assert(alignof(__wasi_filestat_t) == 8, "witx calculated align");
 static_assert(offsetof(__wasi_filestat_t, dev) == 0, "witx calculated offset");
 static_assert(offsetof(__wasi_filestat_t, ino) == 8, "witx calculated offset");
 static_assert(offsetof(__wasi_filestat_t, filetype) == 16,
-               "witx calculated offset");
+              "witx calculated offset");
 static_assert(offsetof(__wasi_filestat_t, nlink) == 24,
-               "witx calculated offset");
+              "witx calculated offset");
 static_assert(offsetof(__wasi_filestat_t, size) == 32,
-               "witx calculated offset");
+              "witx calculated offset");
 static_assert(offsetof(__wasi_filestat_t, atim) == 40,
-               "witx calculated offset");
+              "witx calculated offset");
 static_assert(offsetof(__wasi_filestat_t, mtim) == 48,
-               "witx calculated offset");
+              "witx calculated offset");
 static_assert(offsetof(__wasi_filestat_t, ctim) == 56,
-               "witx calculated offset");
+              "witx calculated offset");
 
 #define __WASI_ERRNO_SUCCESS (UINT16_C(0))
 #define __WASI_ERRNO_NOENT (UINT16_C(44))
@@ -194,8 +194,8 @@ class WasiInstance {
      *                                      __wasi_timestamp_t *time)
      */
     __wasi_timestamp_t t;
-    results[0].Set<u32>(
-        uvwasi_clock_time_get(uvwasi, params[0].Get<u32>(), params[1].Get<u64>(), &t));
+    results[0].Set<u32>(uvwasi_clock_time_get(uvwasi, params[0].Get<u32>(),
+                                              params[1].Get<u64>(), &t));
     uint32_t time_ptr = params[2].Get<u32>();
     CHECK_RESULT(writeValue<__wasi_timestamp_t>(t, time_ptr, trap));
     return Result::Ok;
@@ -231,9 +231,9 @@ class WasiInstance {
       trace_stream->Writef("path_open : %s\n", path);
     }
     uvwasi_fd_t outfd;
-    results[0].Set<u32>(
-        uvwasi_path_open(uvwasi, dirfd, dirflags, path, path_len, oflags,
-                         fs_rights_base, fs_rights_inherting, fs_flags, &outfd));
+    results[0].Set<u32>(uvwasi_path_open(
+        uvwasi, dirfd, dirflags, path, path_len, oflags, fs_rights_base,
+        fs_rights_inherting, fs_flags, &outfd));
     if (trace_stream) {
       trace_stream->Writef("path_open -> %d\n", results[0].Get<u32>());
     }
@@ -268,8 +268,8 @@ class WasiInstance {
         filestat_ptr, sizeof(__wasi_filestat_t), &filestat, trap));
     uvwasi_serdes_write_filestat_t(filestat, 0, &buf);
     if (trace_stream) {
-      trace_stream->Writef("path_filestat_get -> size=%" PRIu64 " %d\n", buf.st_size,
-                           results[0].Get<u32>());
+      trace_stream->Writef("path_filestat_get -> size=%" PRIu64 " %d\n",
+                           buf.st_size, results[0].Get<u32>());
     }
     return Result::Ok;
   }
@@ -395,8 +395,8 @@ class WasiInstance {
         filestat_ptr, sizeof(__wasi_filestat_t), &filestat, trap));
     uvwasi_serdes_write_filestat_t(filestat, 0, &buf);
     if (trace_stream) {
-      trace_stream->Writef("fd_filestat_get -> size=%" PRIu64 " %d\n", buf.st_size,
-                           results[0].Get<u32>());
+      trace_stream->Writef("fd_filestat_get -> size=%" PRIu64 " %d\n",
+                           buf.st_size, results[0].Get<u32>());
     }
     return Result::Ok;
   }
@@ -477,7 +477,8 @@ class WasiInstance {
           reinterpret_cast<const uint8_t**>(&iovs[i].buf), trap));
     }
     __wasi_ptr_t* out_addr;
-    CHECK_RESULT(getMemPtr<__wasi_ptr_t>(params[3].Get<u32>(), 1, &out_addr, trap));
+    CHECK_RESULT(
+        getMemPtr<__wasi_ptr_t>(params[3].Get<u32>(), 1, &out_addr, trap));
     results[0].Set<u32>(
         uvwasi_fd_write(uvwasi, fd, iovs.data(), iovs.size(), out_addr));
     return Result::Ok;
@@ -537,7 +538,8 @@ class WasiInstance {
     uvwasi_size_t environ_buf_size;
     uvwasi_environ_sizes_get(uvwasi, &environc, &environ_buf_size);
     CHECK_RESULT(writeValue<uint32_t>(environc, params[0].Get<u32>(), trap));
-    CHECK_RESULT(writeValue<uint32_t>(environ_buf_size, params[1].Get<u32>(), trap));
+    CHECK_RESULT(
+        writeValue<uint32_t>(environ_buf_size, params[1].Get<u32>(), trap));
     if (trace_stream) {
       trace_stream->Writef("environ_sizes_get -> %d %d\n", environc,
                            environ_buf_size);
@@ -573,7 +575,8 @@ class WasiInstance {
     uvwasi_size_t arg_buf_size;
     uvwasi_args_sizes_get(uvwasi, &argc, &arg_buf_size);
     CHECK_RESULT(writeValue<uint32_t>(argc, params[0].Get<u32>(), trap));
-    CHECK_RESULT(writeValue<uint32_t>(arg_buf_size, params[1].Get<u32>(), trap));
+    CHECK_RESULT(
+        writeValue<uint32_t>(arg_buf_size, params[1].Get<u32>(), trap));
     if (trace_stream) {
       trace_stream->Writef("args_sizes_get -> %d %d\n", argc, arg_buf_size);
     }
diff --git a/src/interp/interp-wasm-c-api.cc b/src/interp/interp-wasm-c-api.cc
index 44fe0868..14bfa83b 100644
--- a/src/interp/interp-wasm-c-api.cc
+++ b/src/interp/interp-wasm-c-api.cc
@@ -48,7 +48,7 @@ static std::unique_ptr<FileStream> s_stdout_stream;
 static ValueType ToWabtValueType(wasm_valkind_t);
 static wasm_valkind_t FromWabtValueType(ValueType);
 
-static wasm_externkind_t FromWabtExternKind(ExternKind );
+static wasm_externkind_t FromWabtExternKind(ExternKind);
 
 static ValueTypes ToWabtValueTypes(const wasm_valtype_vec_t* types);
 static void FromWabtValueTypes(const ValueTypes&, wasm_valtype_vec_t* out);
@@ -81,17 +81,17 @@ struct wasm_valtype_t {
 struct wasm_externtype_t {
   static std::unique_ptr<wasm_externtype_t> New(std::unique_ptr<ExternType>);
 
-  std::unique_ptr<wasm_externtype_t> Clone() const {
-    return New(I->Clone());
-  }
+  std::unique_ptr<wasm_externtype_t> Clone() const { return New(I->Clone()); }
 
   virtual ~wasm_externtype_t() {}
 
   wasm_externtype_t(const wasm_externtype_t& other) = delete;
-  wasm_externtype_t& operator=(const wasm_externtype_t& other)  = delete;
+  wasm_externtype_t& operator=(const wasm_externtype_t& other) = delete;
 
   template <typename T>
-  T* As() const { return cast<T>(I.get()); }
+  T* As() const {
+    return cast<T>(I.get());
+  }
 
   std::unique_ptr<ExternType> I;
 
@@ -251,7 +251,9 @@ struct wasm_ref_t {
   wasm_ref_t(RefPtr<Object> ptr) : I(ptr) {}
 
   template <typename T>
-  T* As() const { return cast<T>(I.get()); }
+  T* As() const {
+    return cast<T>(I.get());
+  }
 
   RefPtr<Object> I;
 };
@@ -285,9 +287,7 @@ struct wasm_module_t : wasm_ref_t {
     return *this;
   }
 
-  ~wasm_module_t() {
-    wasm_byte_vec_delete(&binary);
-  }
+  ~wasm_module_t() { wasm_byte_vec_delete(&binary); }
   // TODO: This is used for wasm_module_serialize/wasm_module_deserialize.
   // Currently the standard wasm binary bytes are cached here, but it would be
   // better to have a serialization of ModuleDesc instead.
diff --git a/src/interp/interp.cc b/src/interp/interp.cc
index 9b8eb4c5..bba27c9b 100644
--- a/src/interp/interp.cc
+++ b/src/interp/interp.cc
@@ -284,7 +284,7 @@ void Store::Mark(Ref ref) {
 }
 
 void Store::Mark(const RefVec& refs) {
-  for (auto&& ref: refs) {
+  for (auto&& ref : refs) {
     Mark(ref);
   }
 }
@@ -492,8 +492,7 @@ Result Table::Grow(Store& store, u32 count, Ref ref) {
 }
 
 Result Table::Fill(Store& store, u32 offset, Ref ref, u32 size) {
-  if (IsValidRange(offset, size) &&
-      store.HasValueType(ref, type_.element)) {
+  if (IsValidRange(offset, size) && store.HasValueType(ref, type_.element)) {
     std::fill(elements_.begin() + offset, elements_.begin() + offset + size,
               ref);
     return Result::Ok;
@@ -731,11 +730,11 @@ bool DataSegment::IsValidRange(u64 offset, u64 size) const {
 //// Module ////
 Module::Module(Store&, ModuleDesc desc)
     : Object(skind), desc_(std::move(desc)) {
-  for (auto&& import: desc_.imports) {
+  for (auto&& import : desc_.imports) {
     import_types_.emplace_back(import.type);
   }
 
-  for (auto&& export_: desc_.exports) {
+  for (auto&& export_ : desc_.exports) {
     export_types_.emplace_back(export_.type);
   }
 }
@@ -821,7 +820,7 @@ Instance::Ptr Instance::Instantiate(Store& store,
   }
 
   // Exports.
-  for (auto&& desc : mod->desc().exports){
+  for (auto&& desc : mod->desc().exports) {
     Ref ref;
     switch (desc.type.type->kind) {
       case ExternKind::Func:   ref = inst->funcs_[desc.index]; break;
@@ -895,12 +894,11 @@ Instance::Ptr Instance::Instantiate(Store& store,
 
         if (Failed(result)) {
           *out_trap = Trap::New(
-              store,
-              StringPrintf("out of bounds memory access: data segment is "
-                           "out of bounds: [%" PRIu64 ", %" PRIu64
-                           ") >= max value %"
-                           PRIu64, offset, offset + segment.size(),
-                           memory->ByteSize()));
+              store, StringPrintf(
+                         "out of bounds memory access: data segment is "
+                         "out of bounds: [%" PRIu64 ", %" PRIu64
+                         ") >= max value %" PRIu64,
+                         offset, offset + segment.size(), memory->ByteSize()));
           return {};
         }
       } else if (desc.mode == SegmentMode::Declared) {
@@ -950,7 +948,7 @@ void Thread::Mark(Store& store) {
   for (auto&& frame : frames_) {
     frame.Mark(store);
   }
-  for (auto index: refs_) {
+  for (auto index : refs_) {
     store.Mark(values_[index].Get<Ref>());
   }
   store.Mark(exceptions_);
@@ -1048,7 +1046,7 @@ RunResult Thread::Run(Trap::Ptr* out_trap) {
 
 RunResult Thread::Run(int num_instructions, Trap::Ptr* out_trap) {
   DefinedFunc::Ptr func{store_, frames_.back().func};
-  for (;num_instructions > 0; --num_instructions) {
+  for (; num_instructions > 0; --num_instructions) {
     auto result = StepInternal(out_trap);
     if (result != RunResult::Ok) {
       return result;
@@ -2307,8 +2305,7 @@ RunResult Thread::DoSimdShuffle(Instr instr) {
   auto lhs = Pop<S>();
   S result;
   for (u8 i = 0; i < S::lanes; ++i) {
-    result[i] =
-        sel[i] < S::lanes ? lhs[sel[i]] : rhs[sel[i] - S::lanes];
+    result[i] = sel[i] < S::lanes ? lhs[sel[i]] : rhs[sel[i] - S::lanes];
   }
   Push(result);
   return RunResult::Ok;
@@ -2378,7 +2375,7 @@ RunResult Thread::DoSimdExtaddPairwise() {
   using U = typename S::LaneType;
   for (u8 i = 0; i < S::lanes; ++i) {
     u8 laneidx = i * 2;
-    result[i] = U(val[laneidx]) + U(val[laneidx+1]);
+    result[i] = U(val[laneidx]) + U(val[laneidx + 1]);
   }
   Push(result);
   return RunResult::Ok;
@@ -2393,7 +2390,7 @@ RunResult Thread::DoSimdDot() {
   for (u8 i = 0; i < S::lanes; ++i) {
     u8 laneidx = i * 2;
     SL lo = SL(lhs[laneidx]) * SL(rhs[laneidx]);
-    SL hi = SL(lhs[laneidx+1]) * SL(rhs[laneidx+1]);
+    SL hi = SL(lhs[laneidx + 1]) * SL(rhs[laneidx + 1]);
     result[i] = Add(lo, hi);
   }
   Push(result);
@@ -2565,8 +2562,8 @@ std::string Thread::TraceSource::Pick(Index index, Instr instr) {
     }
   }
   auto type = index > num_operands
-    ? Type(ValueType::Void)
-    : instr.op.GetParamType(num_operands - index + 1);
+                  ? Type(ValueType::Void)
+                  : instr.op.GetParamType(num_operands - index + 1);
   if (type == ValueType::Void) {
     // Void should never be displayed normally; we only expect to see it when
     // the stack may have different a different type. This is likely to occur
diff --git a/src/interp/interp.h b/src/interp/interp.h
index fa108774..5c7dd8d3 100644
--- a/src/interp/interp.h
+++ b/src/interp/interp.h
@@ -44,7 +44,8 @@ class ElemSegment;
 class Module;
 class Instance;
 class Thread;
-template <typename T> class RefPtr;
+template <typename T>
+class RefPtr;
 
 using s8 = int8_t;
 using u8 = uint8_t;
@@ -63,8 +64,10 @@ using Buffer = std::vector<u8>;
 using ValueType = wabt::Type;
 using ValueTypes = std::vector<ValueType>;
 
-template <typename T> bool HasType(ValueType);
-template <typename T> void RequireType(ValueType);
+template <typename T>
+bool HasType(ValueType);
+template <typename T>
+void RequireType(ValueType);
 bool IsReference(ValueType);
 bool TypesMatch(ValueType expected, ValueType actual);
 
@@ -142,13 +145,13 @@ struct Simd {
 
   inline T& operator[](u8 idx) {
 #if WABT_BIG_ENDIAN
-    idx = (~idx) & (L-1);
+    idx = (~idx) & (L - 1);
 #endif
     return v[idx];
   }
   inline T operator[](u8 idx) const {
 #if WABT_BIG_ENDIAN
-    idx = (~idx) & (L-1);
+    idx = (~idx) & (L - 1);
 #endif
     return v[idx];
   }
@@ -416,7 +419,7 @@ struct Frame {
   void Mark(Store&);
 
   Ref func;
-  u32 values;  // Height of the value stack at this activation.
+  u32 values;      // Height of the value stack at this activation.
   u32 exceptions;  // Height of the exception stack at this activation.
   u32 offset;      // Istream offset; either the return PC, or the current PC.
 
@@ -439,8 +442,8 @@ class FreeList {
   const T& Get(Index) const;
   T& Get(Index);
 
-  Index size() const;  // 1 greater than the maximum index.
-  Index count() const; // The number of used elements.
+  Index size() const;   // 1 greater than the maximum index.
+  Index count() const;  // The number of used elements.
 
  private:
   // TODO: Optimize memory layout? We could probably store all of this
diff --git a/src/interp/istream.cc b/src/interp/istream.cc
index 301411f5..7ef27688 100644
--- a/src/interp/istream.cc
+++ b/src/interp/istream.cc
@@ -865,7 +865,7 @@ Istream::Offset Istream::Trace(Stream* stream,
       break;
 
     case InstrKind::Imm_Index_Op_N:
-      stream->Writef(" $%u\n", instr.imm_u32); // TODO param/result count?
+      stream->Writef(" $%u\n", instr.imm_u32);  // TODO param/result count?
       break;
 
     case InstrKind::Imm_Index_Index_Op_3:
@@ -899,9 +899,10 @@ Istream::Offset Istream::Trace(Stream* stream,
       break;
 
     case InstrKind::Imm_Index_Offset_Lane_Op_2:
-      stream->Writef(" $%u:%s+$%u, %s (Lane imm: $%u)\n", instr.imm_u32x2_u8.fst,
-                     source->Pick(2, instr).c_str(), instr.imm_u32x2_u8.snd,
-                     source->Pick(1, instr).c_str(), instr.imm_u32x2_u8.idx);
+      stream->Writef(" $%u:%s+$%u, %s (Lane imm: $%u)\n",
+                     instr.imm_u32x2_u8.fst, source->Pick(2, instr).c_str(),
+                     instr.imm_u32x2_u8.snd, source->Pick(1, instr).c_str(),
+                     instr.imm_u32x2_u8.idx);
       break;
 
     case InstrKind::Imm_I32_Op_0:
diff --git a/src/interp/istream.h b/src/interp/istream.h
index c8685507..d671e14b 100644
--- a/src/interp/istream.h
+++ b/src/interp/istream.h
@@ -18,8 +18,8 @@
 #define WABT_INTERP_ISTREAM_H_
 
 #include <cstdint>
-#include <vector>
 #include <string>
+#include <vector>
 
 #include "src/common.h"
 #include "src/opcode.h"
@@ -43,32 +43,32 @@ using ValueType = wabt::Type;
 // simplify instruction decoding, disassembling, and tracing. There is an
 // example of an instruction that uses this encoding on the right.
 enum class InstrKind {
-  Imm_0_Op_0,             // Nop
-  Imm_0_Op_1,             // i32.eqz
-  Imm_0_Op_2,             // i32.add
-  Imm_0_Op_3,             // select
-  Imm_Jump_Op_0,          // br
-  Imm_Jump_Op_1,          // br_if
-  Imm_Index_Op_0,         // global.get
-  Imm_Index_Op_1,         // global.set
-  Imm_Index_Op_2,         // table.set
-  Imm_Index_Op_3,         // memory.fill
-  Imm_Index_Op_N,         // call
-  Imm_Index_Index_Op_3,   // memory.init
-  Imm_Index_Index_Op_N,   // call_indirect
-  Imm_Index_Offset_Op_1,  // i32.load
-  Imm_Index_Offset_Op_2,  // i32.store
-  Imm_Index_Offset_Op_3,  // i32.atomic.rmw.cmpxchg
-  Imm_Index_Offset_Lane_Op_2, // v128.load8_lane
-  Imm_I32_Op_0,           // i32.const
-  Imm_I64_Op_0,           // i64.const
-  Imm_F32_Op_0,           // f32.const
-  Imm_F64_Op_0,           // f64.const
-  Imm_I32_I32_Op_0,       // drop_keep
-  Imm_I8_Op_1,            // i32x4.extract_lane
-  Imm_I8_Op_2,            // i32x4.replace_lane
-  Imm_V128_Op_0,          // v128.const
-  Imm_V128_Op_2,          // i8x16.shuffle
+  Imm_0_Op_0,                  // Nop
+  Imm_0_Op_1,                  // i32.eqz
+  Imm_0_Op_2,                  // i32.add
+  Imm_0_Op_3,                  // select
+  Imm_Jump_Op_0,               // br
+  Imm_Jump_Op_1,               // br_if
+  Imm_Index_Op_0,              // global.get
+  Imm_Index_Op_1,              // global.set
+  Imm_Index_Op_2,              // table.set
+  Imm_Index_Op_3,              // memory.fill
+  Imm_Index_Op_N,              // call
+  Imm_Index_Index_Op_3,        // memory.init
+  Imm_Index_Index_Op_N,        // call_indirect
+  Imm_Index_Offset_Op_1,       // i32.load
+  Imm_Index_Offset_Op_2,       // i32.store
+  Imm_Index_Offset_Op_3,       // i32.atomic.rmw.cmpxchg
+  Imm_Index_Offset_Lane_Op_2,  // v128.load8_lane
+  Imm_I32_Op_0,                // i32.const
+  Imm_I64_Op_0,                // i64.const
+  Imm_F32_Op_0,                // f32.const
+  Imm_F64_Op_0,                // f64.const
+  Imm_I32_I32_Op_0,            // drop_keep
+  Imm_I8_Op_1,                 // i32x4.extract_lane
+  Imm_I8_Op_2,                 // i32x4.replace_lane
+  Imm_V128_Op_0,               // v128.const
+  Imm_V128_Op_2,               // i8x16.shuffle
 };
 
 struct Instr {
@@ -81,8 +81,13 @@ struct Instr {
     u64 imm_u64;
     f64 imm_f64;
     v128 imm_v128;
-    struct { u32 fst, snd; } imm_u32x2;
-    struct { u32 fst, snd; u8 idx; } imm_u32x2_u8;
+    struct {
+      u32 fst, snd;
+    } imm_u32x2;
+    struct {
+      u32 fst, snd;
+      u8 idx;
+    } imm_u32x2_u8;
   };
 };
 
@@ -142,7 +147,7 @@ class Istream {
 
   Offset Trace(Stream*, Offset, TraceSource*) const;
 
-private:
+ private:
   template <typename T>
   void WABT_VECTORCALL EmitAt(Offset, T val);
   template <typename T>
-- 
cgit v1.2.3