summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-12-20 19:35:01 -0800
committerGitHub <noreply@github.com>2021-12-20 19:35:01 -0800
commite59cf9369004a521814222afbc05ae6b59446cd5 (patch)
treed1a0483a4e6ec6334182a42bf1d0a532f9e3b8e9
parent8b92c44494ea3c03b38c12275098b682071b6101 (diff)
downloadwabt-e59cf9369004a521814222afbc05ae6b59446cd5.tar.gz
wabt-e59cf9369004a521814222afbc05ae6b59446cd5.tar.bz2
wabt-e59cf9369004a521814222afbc05ae6b59446cd5.zip
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.
-rw-r--r--src/apply-names.cc16
-rw-r--r--src/binary-reader-ir.cc79
-rw-r--r--src/binary-reader-logging.cc5
-rw-r--r--src/binary-reader-nop.h16
-rw-r--r--src/binary-reader-objdump.cc12
-rw-r--r--src/binary-reader.h3
-rw-r--r--src/binary-writer.cc99
-rw-r--r--src/binary.cc26
-rw-r--r--src/c-writer.cc8
-rw-r--r--src/common.cc2
-rw-r--r--src/common.h59
-rw-r--r--src/config.cc4
-rw-r--r--src/decompiler-ast.h85
-rw-r--r--src/decompiler-ls.h39
-rw-r--r--src/decompiler-naming.h8
-rw-r--r--src/decompiler.cc163
-rw-r--r--src/decompiler.h3
-rw-r--r--src/error-formatter.h2
-rw-r--r--src/expr-visitor.cc1
-rw-r--r--src/generate-names.cc7
-rw-r--r--src/interp/binary-reader-interp.cc6
-rw-r--r--src/interp/interp-inl.h26
-rw-r--r--src/interp/interp-math.h16
-rw-r--r--src/interp/interp-util.h2
-rw-r--r--src/interp/interp-wasi.cc47
-rw-r--r--src/interp/interp-wasm-c-api.cc20
-rw-r--r--src/interp/interp.cc37
-rw-r--r--src/interp/interp.h19
-rw-r--r--src/interp/istream.cc9
-rw-r--r--src/interp/istream.h65
-rw-r--r--src/intrusive-list.h8
-rw-r--r--src/ir-util.cc72
-rw-r--r--src/ir-util.h7
-rw-r--r--src/ir.cc127
-rw-r--r--src/ir.h45
-rw-r--r--src/literal.cc15
-rw-r--r--src/opcode-code-table.h2
-rw-r--r--src/opcode.cc2
-rw-r--r--src/opcode.h3
-rw-r--r--src/option-parser.cc1
-rw-r--r--src/resolve-names.cc6
-rw-r--r--src/shared-validator.cc6
-rw-r--r--src/shared-validator.h14
-rw-r--r--src/stream.cc4
-rw-r--r--src/string-view.cc25
-rw-r--r--src/string-view.h65
-rw-r--r--src/test-binary-reader.cc2
-rw-r--r--src/test-interp.cc35
-rw-r--r--src/test-literal.cc545
-rw-r--r--src/test-option-parser.cc1
-rw-r--r--src/tools/spectest-interp.cc71
-rw-r--r--src/tools/wasm-decompile.cc25
-rw-r--r--src/tools/wasm-interp.cc17
-rw-r--r--src/tools/wasm-objdump.cc8
-rw-r--r--src/tools/wasm-opcodecnt.cc13
-rw-r--r--src/tools/wasm-strip.cc9
-rw-r--r--src/tools/wasm-validate.cc4
-rw-r--r--src/tools/wasm2c.cc3
-rw-r--r--src/tools/wasm2wat.cc4
-rw-r--r--src/tools/wast2json.cc6
-rw-r--r--src/tools/wat-desugar.cc2
-rw-r--r--src/tools/wat2wasm.cc4
-rw-r--r--src/type-checker.cc13
-rw-r--r--src/type-checker.h18
-rw-r--r--src/type.h2
-rw-r--r--src/utf8.cc2
-rw-r--r--src/validator.cc13
-rw-r--r--src/validator.h2
-rw-r--r--src/wast-parser.cc29
-rw-r--r--src/wat-writer.cc17
70 files changed, 1120 insertions, 1011 deletions
diff --git a/src/apply-names.cc b/src/apply-names.cc
index 49341c56..b5b11c47 100644
--- a/src/apply-names.cc
+++ b/src/apply-names.cc
@@ -254,12 +254,12 @@ Result NameApplier::OnDataDropExpr(DataDropExpr* expr) {
return Result::Ok;
}
-Result NameApplier::OnMemoryInitExpr(MemoryInitExpr* expr) {
+Result NameApplier::OnMemoryInitExpr(MemoryInitExpr* expr) {
CHECK_RESULT(UseNameForDataSegmentVar(&expr->var));
return Result::Ok;
}
-Result NameApplier::OnElemDropExpr(ElemDropExpr* expr) {
+Result NameApplier::OnElemDropExpr(ElemDropExpr* expr) {
CHECK_RESULT(UseNameForElemSegmentVar(&expr->var));
return Result::Ok;
}
@@ -270,33 +270,33 @@ Result NameApplier::OnTableCopyExpr(TableCopyExpr* expr) {
return Result::Ok;
}
-Result NameApplier::OnTableInitExpr(TableInitExpr* expr) {
+Result NameApplier::OnTableInitExpr(TableInitExpr* expr) {
CHECK_RESULT(UseNameForElemSegmentVar(&expr->segment_index));
CHECK_RESULT(UseNameForTableVar(&expr->table_index));
return Result::Ok;
}
-Result NameApplier::OnTableGetExpr(TableGetExpr* expr) {
+Result NameApplier::OnTableGetExpr(TableGetExpr* expr) {
CHECK_RESULT(UseNameForTableVar(&expr->var));
return Result::Ok;
}
-Result NameApplier::OnTableSetExpr(TableSetExpr* expr) {
+Result NameApplier::OnTableSetExpr(TableSetExpr* expr) {
CHECK_RESULT(UseNameForTableVar(&expr->var));
return Result::Ok;
}
-Result NameApplier::OnTableGrowExpr(TableGrowExpr* expr) {
+Result NameApplier::OnTableGrowExpr(TableGrowExpr* expr) {
CHECK_RESULT(UseNameForTableVar(&expr->var));
return Result::Ok;
}
-Result NameApplier::OnTableSizeExpr(TableSizeExpr* expr) {
+Result NameApplier::OnTableSizeExpr(TableSizeExpr* expr) {
CHECK_RESULT(UseNameForTableVar(&expr->var));
return Result::Ok;
}
-Result NameApplier::OnTableFillExpr(TableFillExpr* expr) {
+Result NameApplier::OnTableFillExpr(TableFillExpr* expr) {
CHECK_RESULT(UseNameForTableVar(&expr->var));
return Result::Ok;
}
diff --git a/src/binary-reader-ir.cc b/src/binary-reader-ir.cc
index 01362e1e..bc2fc2dd 100644
--- a/src/binary-reader-ir.cc
+++ b/src/binary-reader-ir.cc
@@ -45,9 +45,7 @@ LabelNode::LabelNode(LabelType label_type, ExprList* exprs, Expr* context)
class BinaryReaderIR : public BinaryReaderNop {
public:
- BinaryReaderIR(Module* out_module,
- const char* filename,
- Errors* errors);
+ BinaryReaderIR(Module* out_module, const char* filename, Errors* errors);
bool OnError(const Error&) override;
@@ -259,19 +257,30 @@ class BinaryReaderIR : public BinaryReaderNop {
Result OnTagType(Index index, Index sig_index) override;
Result EndTagSection() override { return Result::Ok; }
- Result OnDataSymbol(Index index, uint32_t flags, string_view name,
- Index segment, uint32_t offset, uint32_t size) override;
- Result OnFunctionSymbol(Index index, uint32_t flags, string_view name,
- Index func_index) override;
- Result OnGlobalSymbol(Index index, uint32_t flags, string_view name,
- Index global_index) override;
- Result OnSectionSymbol(Index index, uint32_t flags,
- Index section_index) override;
+ Result OnDataSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index segment,
+ uint32_t offset,
+ uint32_t size) override;
+ Result OnFunctionSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index func_index) override;
+ Result OnGlobalSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index global_index) override;
+ Result OnSectionSymbol(Index index,
+ uint32_t flags,
+ Index section_index) override;
Result OnTagSymbol(Index index,
uint32_t flags,
string_view name,
Index tag_index) override;
- Result OnTableSymbol(Index index, uint32_t flags, string_view name,
+ Result OnTableSymbol(Index index,
+ uint32_t flags,
+ string_view name,
Index table_index) override;
private:
@@ -756,7 +765,8 @@ Result BinaryReaderIR::OnReturnCallExpr(Index func_index) {
return AppendExpr(MakeUnique<ReturnCallExpr>(Var(func_index)));
}
-Result BinaryReaderIR::OnReturnCallIndirectExpr(Index sig_index, Index table_index) {
+Result BinaryReaderIR::OnReturnCallIndirectExpr(Index sig_index,
+ Index table_index) {
auto expr = MakeUnique<ReturnCallIndirectExpr>();
SetFuncDeclaration(&expr->decl, Var(sig_index, GetLocation()));
expr->table = Var(table_index);
@@ -1017,7 +1027,8 @@ Result BinaryReaderIR::AppendCatch(Catch&& catch_) {
auto* try_ = cast<TryExpr>(label->context);
- if (catch_.IsCatchAll() && !try_->catches.empty() && try_->catches.back().IsCatchAll()) {
+ if (catch_.IsCatchAll() && !try_->catches.empty() &&
+ try_->catches.back().IsCatchAll()) {
PrintError("only one catch_all allowed in try block");
return Result::Error;
}
@@ -1096,11 +1107,11 @@ Result BinaryReaderIR::OnSimdLoadLaneExpr(Opcode opcode,
}
Result BinaryReaderIR::OnSimdStoreLaneExpr(Opcode opcode,
- Address alignment_log2,
- Address offset,
- uint64_t value) {
- return AppendExpr(
- MakeUnique<SimdStoreLaneExpr>(opcode, 1 << alignment_log2, offset, value));
+ Address alignment_log2,
+ Address offset,
+ uint64_t value) {
+ return AppendExpr(MakeUnique<SimdStoreLaneExpr>(opcode, 1 << alignment_log2,
+ offset, value));
}
Result BinaryReaderIR::OnSimdShuffleOpExpr(Opcode opcode, v128 value) {
@@ -1453,9 +1464,12 @@ Result BinaryReaderIR::OnTagType(Index index, Index sig_index) {
return Result::Ok;
}
-Result BinaryReaderIR::OnDataSymbol(Index index, uint32_t flags,
- string_view name, Index segment,
- uint32_t offset, uint32_t size) {
+Result BinaryReaderIR::OnDataSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index segment,
+ uint32_t offset,
+ uint32_t size) {
if (name.empty()) {
return Result::Ok;
}
@@ -1480,8 +1494,10 @@ Result BinaryReaderIR::OnDataSymbol(Index index, uint32_t flags,
return Result::Ok;
}
-Result BinaryReaderIR::OnFunctionSymbol(Index index, uint32_t flags,
- string_view name, Index func_index) {
+Result BinaryReaderIR::OnFunctionSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index func_index) {
if (name.empty()) {
return Result::Ok;
}
@@ -1501,12 +1517,15 @@ Result BinaryReaderIR::OnFunctionSymbol(Index index, uint32_t flags,
return Result::Ok;
}
-Result BinaryReaderIR::OnGlobalSymbol(Index index, uint32_t flags,
- string_view name, Index global_index) {
+Result BinaryReaderIR::OnGlobalSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index global_index) {
return SetGlobalName(global_index, name);
}
-Result BinaryReaderIR::OnSectionSymbol(Index index, uint32_t flags,
+Result BinaryReaderIR::OnSectionSymbol(Index index,
+ uint32_t flags,
Index section_index) {
return Result::Ok;
}
@@ -1530,8 +1549,10 @@ Result BinaryReaderIR::OnTagSymbol(Index index,
return Result::Ok;
}
-Result BinaryReaderIR::OnTableSymbol(Index index, uint32_t flags,
- string_view name, Index table_index) {
+Result BinaryReaderIR::OnTableSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index table_index) {
return SetTableName(index, name);
}
diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc
index 68501d4e..7e103540 100644
--- a/src/binary-reader-logging.cc
+++ b/src/binary-reader-logging.cc
@@ -525,8 +525,7 @@ Result BinaryReaderLogging::OnDylinkImport(string_view module,
return reader_->OnDylinkImport(module, name, flags);
}
-Result BinaryReaderLogging::OnRelocCount(Index count,
- Index section_index) {
+Result BinaryReaderLogging::OnRelocCount(Index count, Index section_index) {
LOGF("OnRelocCount(count: %" PRIindex ", section: %" PRIindex ")\n", count,
section_index);
return reader_->OnRelocCount(count, section_index);
@@ -603,7 +602,7 @@ Result BinaryReaderLogging::OnTableSymbol(Index index,
string_view name,
Index table_index) {
LOGF("OnTableSymbol(name: " PRIstringview " flags: 0x%x index: %" PRIindex
- ")\n",
+ ")\n",
WABT_PRINTF_STRING_VIEW_ARG(name), flags, table_index);
return reader_->OnTableSymbol(index, flags, name, table_index);
}
diff --git a/src/binary-reader-nop.h b/src/binary-reader-nop.h
index f3aae0e2..1acf1c24 100644
--- a/src/binary-reader-nop.h
+++ b/src/binary-reader-nop.h
@@ -58,9 +58,7 @@ class BinaryReaderNop : public BinaryReaderDelegate {
TypeMut* fields) override {
return Result::Ok;
}
- Result OnArrayType(Index index, TypeMut field) override {
- return Result::Ok;
- }
+ Result OnArrayType(Index index, TypeMut field) override { return Result::Ok; }
Result EndTypeSection() override { return Result::Ok; }
/* Import section */
@@ -221,9 +219,7 @@ class BinaryReaderNop : public BinaryReaderDelegate {
Result OnAtomicWaitExpr(Opcode, Address, Address) override {
return Result::Ok;
}
- Result OnAtomicFenceExpr(uint32_t) override {
- return Result::Ok;
- }
+ Result OnAtomicFenceExpr(uint32_t) override { return Result::Ok; }
Result OnAtomicNotifyExpr(Opcode, Address, Address) override {
return Result::Ok;
}
@@ -237,7 +233,9 @@ class BinaryReaderNop : public BinaryReaderDelegate {
return Result::Ok;
}
Result OnCallExpr(Index func_index) override { return Result::Ok; }
- Result OnCallIndirectExpr(Index sig_index, Index table_index) override { return Result::Ok; }
+ Result OnCallIndirectExpr(Index sig_index, Index table_index) override {
+ return Result::Ok;
+ }
Result OnCallRefExpr() override { return Result::Ok; }
Result OnCatchExpr(Index tag_index) override { return Result::Ok; }
Result OnCatchAllExpr() override { return Result::Ok; }
@@ -293,7 +291,9 @@ class BinaryReaderNop : public BinaryReaderDelegate {
Result OnNopExpr() override { return Result::Ok; }
Result OnRethrowExpr(Index depth) override { return Result::Ok; }
Result OnReturnCallExpr(Index sig_index) override { return Result::Ok; }
- Result OnReturnCallIndirectExpr(Index sig_index, Index table_index) override { return Result::Ok; }
+ Result OnReturnCallIndirectExpr(Index sig_index, Index table_index) override {
+ return Result::Ok;
+ }
Result OnReturnExpr() override { return Result::Ok; }
Result OnSelectExpr(Index result_count, Type* result_types) override {
return Result::Ok;
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index 2ec05ddd..d1863405 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -476,7 +476,9 @@ class BinaryReaderObjdumpDisassemble : public BinaryReaderObjdumpBase {
Result OnOpcodeIndexIndex(Index value, Index value2) override;
Result OnOpcodeUint32(uint32_t value) override;
Result OnOpcodeUint32Uint32(uint32_t value, uint32_t value2) override;
- Result OnOpcodeUint32Uint32Uint32(uint32_t value, uint32_t value2, uint32_t value3) override;
+ Result OnOpcodeUint32Uint32Uint32(uint32_t value,
+ uint32_t value2,
+ uint32_t value3) override;
Result OnOpcodeUint64(uint64_t value) override;
Result OnOpcodeF32(uint32_t value) override;
Result OnOpcodeF64(uint64_t value) override;
@@ -2077,8 +2079,8 @@ Result BinaryReaderObjdump::OnSegmentInfo(Index index,
string_view name,
Address alignment_log2,
uint32_t flags) {
- PrintDetails(" - %d: " PRIstringview " p2align=%" PRIaddress,
- index, WABT_PRINTF_STRING_VIEW_ARG(name), alignment_log2);
+ PrintDetails(" - %d: " PRIstringview " p2align=%" PRIaddress, index,
+ WABT_PRINTF_STRING_VIEW_ARG(name), alignment_log2);
return PrintSegmentFlags(flags);
}
@@ -2097,7 +2099,9 @@ Result BinaryReaderObjdump::OnComdatCount(Index count) {
return Result::Ok;
}
-Result BinaryReaderObjdump::OnComdatBegin(string_view name, uint32_t flags, Index count) {
+Result BinaryReaderObjdump::OnComdatBegin(string_view name,
+ uint32_t flags,
+ Index count) {
PrintDetails(" - " PRIstringview ": [count=%d]\n",
WABT_PRINTF_STRING_VIEW_ARG(name), count);
return Result::Ok;
diff --git a/src/binary-reader.h b/src/binary-reader.h
index d000dd9b..b38e6c9c 100644
--- a/src/binary-reader.h
+++ b/src/binary-reader.h
@@ -382,8 +382,7 @@ class BinaryReaderDelegate {
/* Reloc section */
virtual Result BeginRelocSection(Offset size) = 0;
- virtual Result OnRelocCount(Index count,
- Index section_index) = 0;
+ virtual Result OnRelocCount(Index count, Index section_index) = 0;
virtual Result OnReloc(RelocType type,
Offset offset,
Index index,
diff --git a/src/binary-writer.cc b/src/binary-writer.cc
index d7b0154c..6dee779d 100644
--- a/src/binary-writer.cc
+++ b/src/binary-writer.cc
@@ -178,7 +178,9 @@ class Symbol {
bool undefined() const { return flags() & WABT_SYMBOL_FLAG_UNDEFINED; }
bool defined() const { return !undefined(); }
bool exported() const { return flags() & WABT_SYMBOL_FLAG_EXPORTED; }
- bool explicit_name() const { return flags() & WABT_SYMBOL_FLAG_EXPLICIT_NAME; }
+ bool explicit_name() const {
+ return flags() & WABT_SYMBOL_FLAG_EXPLICIT_NAME;
+ }
bool no_strip() const { return flags() & WABT_SYMBOL_FLAG_NO_STRIP; }
bool IsFunction() const { return type() == Function::type; }
@@ -227,8 +229,10 @@ class SymbolTable {
Result EnsureUnique(const string_view& name) {
if (seen_names_.count(name)) {
- fprintf(stderr, "error: duplicate symbol when writing relocatable "
- "binary: %s\n", &name[0]);
+ fprintf(stderr,
+ "error: duplicate symbol when writing relocatable "
+ "binary: %s\n",
+ &name[0]);
return Result::Error;
}
seen_names_.insert(name);
@@ -236,8 +240,11 @@ class SymbolTable {
};
template <typename T>
- Result AddSymbol(std::vector<Index>* map, string_view name,
- bool imported, bool exported, T&& sym) {
+ Result AddSymbol(std::vector<Index>* map,
+ string_view name,
+ bool imported,
+ bool exported,
+ T&& sym) {
uint8_t flags = 0;
if (imported) {
flags |= WABT_SYMBOL_FLAG_UNDEFINED;
@@ -290,20 +297,20 @@ class SymbolTable {
for (const Export* export_ : module->exports) {
switch (export_->kind) {
- case ExternalKind::Func:
- exported_funcs.insert(module->GetFuncIndex(export_->var));
- break;
- case ExternalKind::Table:
- exported_tables.insert(module->GetTableIndex(export_->var));
- break;
- case ExternalKind::Memory:
- break;
- case ExternalKind::Global:
- exported_globals.insert(module->GetGlobalIndex(export_->var));
- break;
- case ExternalKind::Tag:
- exported_tags.insert(module->GetTagIndex(export_->var));
- break;
+ case ExternalKind::Func:
+ exported_funcs.insert(module->GetFuncIndex(export_->var));
+ break;
+ case ExternalKind::Table:
+ exported_tables.insert(module->GetTableIndex(export_->var));
+ break;
+ case ExternalKind::Memory:
+ break;
+ case ExternalKind::Global:
+ exported_globals.insert(module->GetGlobalIndex(export_->var));
+ break;
+ case ExternalKind::Tag:
+ exported_tags.insert(module->GetTagIndex(export_->var));
+ break;
}
}
@@ -504,7 +511,8 @@ void BinaryWriter::WriteBlockDecl(const BlockDeclaration& decl) {
Index index = decl.has_func_type ? module_->GetFuncTypeIndex(decl.type_var)
: module_->GetFuncTypeIndex(decl.sig);
assert(index != kInvalidIndex);
- WriteS32Leb128WithReloc(index, "block type function index", RelocType::TypeIndexLEB);
+ WriteS32Leb128WithReloc(index, "block type function index",
+ RelocType::TypeIndexLEB);
}
void BinaryWriter::WriteSectionHeader(const char* desc,
@@ -589,7 +597,8 @@ void BinaryWriter::AddReloc(RelocType reloc_type, Index index) {
// Add a new reloc section if needed
if (!current_reloc_section_ ||
current_reloc_section_->section_index != section_count_) {
- reloc_sections_.emplace_back(GetSectionName(last_section_type_), section_count_);
+ reloc_sections_.emplace_back(GetSectionName(last_section_type_),
+ section_count_);
current_reloc_section_ = &reloc_sections_.back();
}
@@ -628,8 +637,7 @@ void BinaryWriter::WriteS32Leb128WithReloc(int32_t value,
}
}
-void BinaryWriter::WriteTableNumberWithReloc(Index value,
- const char* desc) {
+void BinaryWriter::WriteTableNumberWithReloc(Index value, const char* desc) {
// Unless reference types are enabled, all references to tables refer to table
// 0, so no relocs need be emitted when making relocatable binaries.
if (options_.relocatable && options_.features.reference_types_enabled()) {
@@ -753,7 +761,7 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) {
WriteU32Leb128(stream_, depth, "break depth for default");
break;
}
- case ExprType::Call:{
+ case ExprType::Call: {
Index index = module_->GetFuncIndex(cast<CallExpr>(expr)->var);
WriteOpcode(stream_, Opcode::Call);
WriteU32Leb128WithReloc(index, "function index", RelocType::FuncIndexLEB);
@@ -765,17 +773,18 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) {
WriteU32Leb128WithReloc(index, "function index", RelocType::FuncIndexLEB);
break;
}
- case ExprType::CallIndirect:{
+ case ExprType::CallIndirect: {
Index sig_index =
- module_->GetFuncTypeIndex(cast<CallIndirectExpr>(expr)->decl);
+ module_->GetFuncTypeIndex(cast<CallIndirectExpr>(expr)->decl);
Index table_index =
- module_->GetTableIndex(cast<CallIndirectExpr>(expr)->table);
+ module_->GetTableIndex(cast<CallIndirectExpr>(expr)->table);
WriteOpcode(stream_, Opcode::CallIndirect);
- WriteU32Leb128WithReloc(sig_index, "signature index", RelocType::TypeIndexLEB);
+ WriteU32Leb128WithReloc(sig_index, "signature index",
+ RelocType::TypeIndexLEB);
WriteTableNumberWithReloc(table_index, "table index");
break;
}
- case ExprType::CallRef:{
+ case ExprType::CallRef: {
WriteOpcode(stream_, Opcode::CallRef);
break;
}
@@ -785,7 +794,8 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) {
Index table_index =
module_->GetTableIndex(cast<ReturnCallIndirectExpr>(expr)->table);
WriteOpcode(stream_, Opcode::ReturnCallIndirect);
- WriteU32Leb128WithReloc(sig_index, "signature index", RelocType::TypeIndexLEB);
+ WriteU32Leb128WithReloc(sig_index, "signature index",
+ RelocType::TypeIndexLEB);
WriteTableNumberWithReloc(table_index, "table index");
break;
}
@@ -889,8 +899,7 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) {
break;
}
case ExprType::DataDrop: {
- Index index =
- module_->GetDataSegmentIndex(cast<DataDropExpr>(expr)->var);
+ Index index = module_->GetDataSegmentIndex(cast<DataDropExpr>(expr)->var);
WriteOpcode(stream_, Opcode::DataDrop);
WriteU32Leb128(stream_, index, "data.drop segment");
has_data_segment_instruction_ = true;
@@ -938,8 +947,7 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) {
break;
}
case ExprType::ElemDrop: {
- Index index =
- module_->GetElemSegmentIndex(cast<ElemDropExpr>(expr)->var);
+ Index index = module_->GetElemSegmentIndex(cast<ElemDropExpr>(expr)->var);
WriteOpcode(stream_, Opcode::ElemDrop);
WriteU32Leb128(stream_, index, "elem.drop segment");
break;
@@ -955,36 +963,31 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) {
break;
}
case ExprType::TableGet: {
- Index index =
- module_->GetTableIndex(cast<TableGetExpr>(expr)->var);
+ Index index = module_->GetTableIndex(cast<TableGetExpr>(expr)->var);
WriteOpcode(stream_, Opcode::TableGet);
WriteTableNumberWithReloc(index, "table.get table index");
break;
}
case ExprType::TableSet: {
- Index index =
- module_->GetTableIndex(cast<TableSetExpr>(expr)->var);
+ Index index = module_->GetTableIndex(cast<TableSetExpr>(expr)->var);
WriteOpcode(stream_, Opcode::TableSet);
WriteTableNumberWithReloc(index, "table.set table index");
break;
}
case ExprType::TableGrow: {
- Index index =
- module_->GetTableIndex(cast<TableGrowExpr>(expr)->var);
+ Index index = module_->GetTableIndex(cast<TableGrowExpr>(expr)->var);
WriteOpcode(stream_, Opcode::TableGrow);
WriteTableNumberWithReloc(index, "table.grow table index");
break;
}
case ExprType::TableSize: {
- Index index =
- module_->GetTableIndex(cast<TableSizeExpr>(expr)->var);
+ Index index = module_->GetTableIndex(cast<TableSizeExpr>(expr)->var);
WriteOpcode(stream_, Opcode::TableSize);
WriteTableNumberWithReloc(index, "table.size table index");
break;
}
case ExprType::TableFill: {
- Index index =
- module_->GetTableIndex(cast<TableFillExpr>(expr)->var);
+ Index index = module_->GetTableIndex(cast<TableFillExpr>(expr)->var);
WriteOpcode(stream_, Opcode::TableFill);
WriteTableNumberWithReloc(index, "table.fill table index");
break;
@@ -1056,8 +1059,7 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) {
break;
case TryKind::Delegate:
WriteOpcode(stream_, Opcode::Delegate);
- WriteU32Leb128(stream_,
- GetLabelVarDepth(&try_expr->delegate_target),
+ WriteU32Leb128(stream_, GetLabelVarDepth(&try_expr->delegate_target),
"delegate depth");
break;
case TryKind::Plain:
@@ -1584,10 +1586,11 @@ Result BinaryWriter::WriteModule() {
auto func_start_offset = body_size_offset - last_section_payload_offset_;
auto func_end_offset = stream_->offset() - last_section_payload_offset_;
auto delta = WriteFixupU32Leb128Size(body_size_offset, leb_size_guess,
- "FIXUP func body size");
+ "FIXUP func body size");
if (current_reloc_section_ && delta != 0) {
for (Reloc& reloc : current_reloc_section_->relocations) {
- if (reloc.offset >= func_start_offset && reloc.offset <= func_end_offset) {
+ if (reloc.offset >= func_start_offset &&
+ reloc.offset <= func_end_offset) {
reloc.offset += delta;
}
}
diff --git a/src/binary.cc b/src/binary.cc
index 96103b4a..14ed98ce 100644
--- a/src/binary.cc
+++ b/src/binary.cc
@@ -25,8 +25,8 @@ BinarySectionOrder GetSectionOrder(BinarySection sec) {
return BinarySectionOrder::Name;
WABT_FOREACH_BINARY_SECTION(V)
#undef V
- default:
- WABT_UNREACHABLE;
+ default:
+ WABT_UNREACHABLE;
}
}
@@ -44,17 +44,17 @@ const char* GetSectionName(BinarySection sec) {
// clang-format off
const char* NameSubsectionName[] = {
- "module",
- "function",
- "local",
- "label",
- "type",
- "table",
- "memory",
- "global",
- "elemseg",
- "dataseg",
- "tag",
+ "module",
+ "function",
+ "local",
+ "label",
+ "type",
+ "table",
+ "memory",
+ "global",
+ "elemseg",
+ "dataseg",
+ "tag",
};
// clang-format on
diff --git a/src/c-writer.cc b/src/c-writer.cc
index d4381a6e..d143eeb3 100644
--- a/src/c-writer.cc
+++ b/src/c-writer.cc
@@ -48,9 +48,7 @@ struct Label {
type_stack_size(type_stack_size),
used(used) {}
- bool HasValue() const {
- return !sig.empty();
- }
+ bool HasValue() const { return !sig.empty(); }
LabelType label_type;
const std::string& name;
@@ -636,7 +634,8 @@ void CWriter::Write(const GotoLabel& goto_label) {
Index offset = type_stack_.size() - label->type_stack_size - amount;
if (offset != 0) {
for (Index i = 0; i < amount; ++i) {
- Write(StackVar(amount - i - 1 + offset, label->sig[i]), " = ", StackVar(amount - i - 1), "; ");
+ Write(StackVar(amount - i - 1 + offset, label->sig[i]), " = ",
+ StackVar(amount - i - 1), "; ");
}
}
}
@@ -844,7 +843,6 @@ void CWriter::WriteMultivalueTypes() {
}
}
-
void CWriter::WriteFuncTypes() {
Write(Newline());
Writef("static u32 func_types[%" PRIzd "];", module_->types.size());
diff --git a/src/common.cc b/src/common.cc
index 6fe754a2..706a013f 100644
--- a/src/common.cc
+++ b/src/common.cc
@@ -22,8 +22,8 @@
#include <cstdio>
#include <cstring>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
#if COMPILER_IS_MSVC
#include <fcntl.h>
diff --git a/src/common.h b/src/common.h
index a385b921..72fab59d 100644
--- a/src/common.h
+++ b/src/common.h
@@ -44,11 +44,12 @@
#define WABT_USE(x) static_cast<void>(x)
-#define WABT_PAGE_SIZE 0x10000 /* 64k */
-#define WABT_MAX_PAGES32 0x10000 /* # of pages that fit in 32-bit address \
- space */
-#define WABT_MAX_PAGES64 0x1000000000000 /* # of pages that fit in 64-bit \
- address space */
+// 64k
+#define WABT_PAGE_SIZE 0x10000
+// # of pages that fit in 32-bit address space
+#define WABT_MAX_PAGES32 0x10000
+// # of pages that fit in 64-bit address space
+#define WABT_MAX_PAGES64 0x1000000000000
#define WABT_BYTES_TO_PAGES(x) ((x) >> 16)
#define WABT_ALIGN_UP_TO_PAGE(x) \
(((x) + WABT_PAGE_SIZE - 1) & ~(WABT_PAGE_SIZE - 1))
@@ -83,17 +84,27 @@
namespace wabt {
#if WABT_BIG_ENDIAN
- inline void MemcpyEndianAware(void *dst, const void *src, size_t dsize, size_t ssize, size_t doff, size_t soff, size_t len) {
- memcpy(static_cast<char*>(dst) + (dsize) - (len) - (doff),
- static_cast<const char*>(src) + (ssize) - (len) - (soff),
- (len));
- }
+inline void MemcpyEndianAware(void* dst,
+ const void* src,
+ size_t dsize,
+ size_t ssize,
+ size_t doff,
+ size_t soff,
+ size_t len) {
+ memcpy(static_cast<char*>(dst) + (dsize) - (len) - (doff),
+ static_cast<const char*>(src) + (ssize) - (len) - (soff), (len));
+}
#else
- inline void MemcpyEndianAware(void *dst, const void *src, size_t dsize, size_t ssize, size_t doff, size_t soff, size_t len) {
- memcpy(static_cast<char*>(dst) + (doff),
- static_cast<const char*>(src) + (soff),
- (len));
- }
+inline void MemcpyEndianAware(void* dst,
+ const void* src,
+ size_t dsize,
+ size_t ssize,
+ size_t doff,
+ size_t soff,
+ size_t len) {
+ memcpy(static_cast<char*>(dst) + (doff),
+ static_cast<const char*>(src) + (soff), (len));
+}
#endif
}
@@ -136,7 +147,8 @@ struct v128 {
static_assert(sizeof(T) <= sizeof(v), "Invalid cast!");
assert((lane + 1) * sizeof(T) <= sizeof(v));
T result;
- wabt::MemcpyEndianAware(&result, v, sizeof(result), sizeof(v), 0, lane * sizeof(T), sizeof(result));
+ wabt::MemcpyEndianAware(&result, v, sizeof(result), sizeof(v), 0,
+ lane * sizeof(T), sizeof(result));
return result;
}
@@ -144,7 +156,8 @@ struct v128 {
void From(int lane, T data) {
static_assert(sizeof(T) <= sizeof(v), "Invalid cast!");
assert((lane + 1) * sizeof(T) <= sizeof(v));
- wabt::MemcpyEndianAware(v, &data, sizeof(v), sizeof(data), lane * sizeof(T), 0, sizeof(data));
+ wabt::MemcpyEndianAware(v, &data, sizeof(v), sizeof(data), lane * sizeof(T),
+ 0, sizeof(data));
}
uint8_t v[16];
@@ -385,8 +398,8 @@ extern const char* g_kind_name[];
static WABT_INLINE const char* GetKindName(ExternalKind kind) {
return static_cast<size_t>(kind) < kExternalKindCount
- ? g_kind_name[static_cast<size_t>(kind)]
- : "<error_kind>";
+ ? g_kind_name[static_cast<size_t>(kind)]
+ : "<error_kind>";
}
/* reloc */
@@ -395,8 +408,8 @@ extern const char* g_reloc_type_name[];
static WABT_INLINE const char* GetRelocTypeName(RelocType reloc) {
return static_cast<size_t>(reloc) < kRelocTypeCount
- ? g_reloc_type_name[static_cast<size_t>(reloc)]
- : "<error_reloc_type>";
+ ? g_reloc_type_name[static_cast<size_t>(reloc)]
+ : "<error_reloc_type>";
}
/* symbol */
@@ -437,10 +450,10 @@ inline void ConvertBackslashToSlash(std::string* s) {
ConvertBackslashToSlash(s->begin(), s->end());
}
-inline void SwapBytesSized(void *addr, size_t size) {
+inline void SwapBytesSized(void* addr, size_t size) {
auto bytes = static_cast<uint8_t*>(addr);
for (size_t i = 0; i < size / 2; i++) {
- std::swap(bytes[i], bytes[size-1-i]);
+ std::swap(bytes[i], bytes[size - 1 - i]);
}
}
diff --git a/src/config.cc b/src/config.cc
index 9347c860..00f60aa8 100644
--- a/src/config.cc
+++ b/src/config.cc
@@ -55,7 +55,7 @@ int wabt_snprintf(char* str, size_t size, const char* format, ...) {
// Allow the following functions to change the floating-point environment (e.g.
// update to 64-bit precision in the mantissa). This is only needed for x87
// floats, which are only used on MSVC 32-bit.
-#pragma fenv_access (on)
+#pragma fenv_access(on)
namespace {
typedef unsigned int FPControl;
@@ -158,5 +158,5 @@ float wabt_convert_int64_to_float(int64_t x) {
}
#if COMPILER_IS_MSVC && _M_IX86
-#pragma fenv_access (off)
+#pragma fenv_access(off)
#endif
diff --git a/src/decompiler-ast.h b/src/decompiler-ast.h
index ec5b3880..b02bc76b 100644
--- a/src/decompiler-ast.h
+++ b/src/decompiler-ast.h
@@ -19,8 +19,8 @@
#include "src/cast.h"
#include "src/generate-names.h"
-#include "src/ir.h"
#include "src/ir-util.h"
+#include "src/ir.h"
#include <map>
@@ -45,15 +45,16 @@ struct Node {
std::vector<Node> children;
// Node specific annotations.
union {
- struct { Index var_start, var_count; }; // FlushedVar/FlushToVars
+ struct {
+ Index var_start, var_count; // FlushedVar/FlushToVars
+ };
const Var* var; // Decl/DeclInit.
- LabelType lt; // br/br_if target.
+ LabelType lt; // br/br_if target.
} u;
- Node() : ntype(NodeType::Uninitialized), etype(ExprType::Nop), e(nullptr) {
- }
+ Node() : ntype(NodeType::Uninitialized), etype(ExprType::Nop), e(nullptr) {}
Node(NodeType ntype, ExprType etype, const Expr* e, const Var* v)
- : ntype(ntype), etype(etype), e(e) {
+ : ntype(ntype), etype(etype), e(e) {
u.var = v;
}
@@ -76,24 +77,26 @@ struct Node {
};
struct AST {
- AST(ModuleContext& mc, const Func *f) : mc(mc), f(f) {
+ AST(ModuleContext& mc, const Func* f) : mc(mc), f(f) {
if (f) {
mc.BeginFunc(*f);
for (Index i = 0; i < f->GetNumParams(); i++) {
auto name = "$" + IndexToAlphaName(i);
- vars_defined.insert({ name, { 0, false }});
+ vars_defined.insert({name, {0, false}});
}
}
}
~AST() {
- if (f) mc.EndFunc();
+ if (f) {
+ mc.EndFunc();
+ }
}
// Create a new node, take nargs existing nodes on the exp stack as children.
Node& InsertNode(NodeType ntype, ExprType etype, const Expr* e, Index nargs) {
assert(exp_stack.size() >= nargs);
- Node n { ntype, etype, e, nullptr };
+ Node n{ntype, etype, e, nullptr};
n.children.reserve(nargs);
std::move(exp_stack.end() - nargs, exp_stack.end(),
std::back_inserter(n.children));
@@ -102,7 +105,8 @@ struct AST {
return exp_stack.back();
}
- template<ExprType T> void PreDecl(const VarExpr<T>& ve) {
+ template <ExprType T>
+ void PreDecl(const VarExpr<T>& ve) {
// FIXME: this is slow, and would be better to avoid in callers.
// See https://github.com/WebAssembly/wabt/issues/1565
// And https://github.com/WebAssembly/wabt/issues/1665
@@ -114,9 +118,10 @@ struct AST {
predecls.emplace_back(NodeType::Decl, ExprType::Nop, nullptr, &ve.var);
}
- template<ExprType T> void Get(const VarExpr<T>& ve, bool local) {
+ template <ExprType T>
+ void Get(const VarExpr<T>& ve, bool local) {
if (local) {
- auto ret = vars_defined.insert({ ve.var.name(), { cur_block_id, false }});
+ auto ret = vars_defined.insert({ve.var.name(), {cur_block_id, false}});
if (ret.second) {
// Use before def, may happen since locals are guaranteed 0.
PreDecl(ve);
@@ -130,10 +135,11 @@ struct AST {
InsertNode(NodeType::Expr, T, &ve, 0);
}
- template<ExprType T> void Set(const VarExpr<T>& ve, bool local) {
+ template <ExprType T>
+ void Set(const VarExpr<T>& ve, bool local) {
// Seen this var before?
if (local &&
- vars_defined.insert({ ve.var.name(), { cur_block_id, false }}).second) {
+ vars_defined.insert({ve.var.name(), {cur_block_id, false}}).second) {
if (value_stack_depth == 1) {
// Top level, declare it here.
InsertNode(NodeType::DeclInit, ExprType::Nop, nullptr, 1).u.var =
@@ -147,9 +153,11 @@ struct AST {
InsertNode(NodeType::Expr, T, &ve, 1);
}
- template<ExprType T> void Block(const BlockExprBase<T>& be, LabelType label) {
+ template <ExprType T>
+ void Block(const BlockExprBase<T>& be, LabelType label) {
mc.BeginBlock(label, be.block);
- Construct(be.block.exprs, be.block.decl.GetNumResults(), be.block.decl.GetNumParams(), false);
+ Construct(be.block.exprs, be.block.decl.GetNumResults(),
+ be.block.decl.GetNumParams(), false);
mc.EndBlock();
InsertNode(NodeType::Expr, T, &be, 1);
}
@@ -177,7 +185,7 @@ struct AST {
auto& lt = *cast<LocalTeeExpr>(&e);
Set(lt, true);
if (value_stack_depth == 1) { // Tee is the only thing on there.
- Get(lt, true); // Now Set + Get instead.
+ Get(lt, true); // Now Set + Get instead.
} else {
// Things are above us on the stack so the Tee can't be eliminated.
// The Set makes this work as a Tee when consumed by a parent.
@@ -188,13 +196,16 @@ struct AST {
auto ife = cast<IfExpr>(&e);
value_stack_depth--; // Condition.
mc.BeginBlock(LabelType::Block, ife->true_);
- Construct(ife->true_.exprs, ife->true_.decl.GetNumResults(), ife->true_.decl.GetNumParams(), false);
+ Construct(ife->true_.exprs, ife->true_.decl.GetNumResults(),
+ ife->true_.decl.GetNumParams(), false);
if (!ife->false_.empty()) {
- Construct(ife->false_, ife->true_.decl.GetNumResults(), ife->true_.decl.GetNumParams(), false);
+ Construct(ife->false_, ife->true_.decl.GetNumResults(),
+ ife->true_.decl.GetNumParams(), false);
}
mc.EndBlock();
value_stack_depth++; // Put Condition back.
- InsertNode(NodeType::Expr, ExprType::If, &e, ife->false_.empty() ? 2 : 3);
+ InsertNode(NodeType::Expr, ExprType::If, &e,
+ ife->false_.empty() ? 2 : 3);
return;
}
case ExprType::Block: {
@@ -222,7 +233,10 @@ struct AST {
}
}
- void Construct(const ExprList& es, Index nresults, Index nparams, bool is_function_body) {
+ void Construct(const ExprList& es,
+ Index nresults,
+ Index nparams,
+ bool is_function_body) {
block_stack.push_back(cur_block_id);
cur_block_id = blocks_closed.size();
blocks_closed.push_back(false);
@@ -234,8 +248,8 @@ struct AST {
Construct(e);
auto arity = mc.GetExprArity(e);
value_stack_depth -= arity.nargs;
- value_stack_in_variables = std::min(value_stack_in_variables,
- value_stack_depth);
+ value_stack_in_variables =
+ std::min(value_stack_in_variables, value_stack_depth);
unreachable = unreachable || arity.unreachable;
assert(unreachable || value_stack_depth >= value_stack_depth_start);
value_stack_depth += arity.nreturns;
@@ -256,21 +270,20 @@ struct AST {
auto num_vars = value_stack_in_variables - value_stack_depth_start;
auto num_vals = value_stack_depth - value_stack_in_variables;
auto GenFlushVars = [&](int nargs) {
- auto& ftv = InsertNode(NodeType::FlushToVars, ExprType::Nop, nullptr,
- nargs);
+ auto& ftv =
+ InsertNode(NodeType::FlushToVars, ExprType::Nop, nullptr, nargs);
ftv.u.var_start = flushed_vars;
ftv.u.var_count = num_vals;
};
auto MoveStatementsBelowVars = [&](size_t amount) {
std::rotate(exp_stack.end() - num_vars - amount,
- exp_stack.end() - amount,
- exp_stack.end());
+ exp_stack.end() - amount, exp_stack.end());
};
auto GenFlushedVars = [&]() {
// Re-generate these values as vars.
for (int i = 0; i < num_vals; i++) {
- auto& fv = InsertNode(NodeType::FlushedVar, ExprType::Nop, nullptr,
- 0);
+ auto& fv =
+ InsertNode(NodeType::FlushedVar, ExprType::Nop, nullptr, 0);
fv.u.var_start = flushed_vars++;
fv.u.var_count = 1;
}
@@ -325,9 +338,8 @@ struct AST {
}
}
}
- assert(unreachable ||
- value_stack_depth - value_stack_depth_start ==
- static_cast<int>(nresults));
+ assert(unreachable || value_stack_depth - value_stack_depth_start ==
+ static_cast<int>(nresults));
// Undo any changes to value_stack_depth, since parent takes care of arity
// changes.
value_stack_depth = value_stack_depth_start;
@@ -371,9 +383,12 @@ struct AST {
ModuleContext& mc;
std::vector<Node> exp_stack;
std::vector<Node> predecls;
- const Func *f;
+ const Func* f;
int value_stack_depth = 0;
- struct Variable { size_t block_id; bool defined; };
+ struct Variable {
+ size_t block_id;
+ bool defined;
+ };
std::map<std::string, Variable> vars_defined;
Index flushed_vars = 0;
size_t cur_block_id = 0;
diff --git a/src/decompiler-ls.h b/src/decompiler-ls.h
index f622e3fd..ae692711 100644
--- a/src/decompiler-ls.h
+++ b/src/decompiler-ls.h
@@ -24,7 +24,7 @@
namespace wabt {
// Names starting with "u" are unsigned, the rest are "signed or doesn't matter"
-inline const char *GetDecompTypeName(Type t) {
+inline const char* GetDecompTypeName(Type t) {
switch (t) {
case Type::I8: return "byte";
case Type::I8U: return "ubyte";
@@ -84,18 +84,20 @@ struct LoadStoreTracking {
};
void Track(const Node& n) {
- for (auto& c : n.children) Track(c);
+ for (auto& c : n.children) {
+ Track(c);
+ }
switch (n.etype) {
case ExprType::Load: {
auto& le = *cast<LoadExpr>(n.e);
- LoadStore(le.offset, le.opcode, le.opcode.GetResultType(),
- le.align, n.children[0]);
+ LoadStore(le.offset, le.opcode, le.opcode.GetResultType(), le.align,
+ n.children[0]);
break;
}
case ExprType::Store: {
auto& se = *cast<StoreExpr>(n.e);
- LoadStore(se.offset, se.opcode, se.opcode.GetParamType2(),
- se.align, n.children[0]);
+ LoadStore(se.offset, se.opcode, se.opcode.GetParamType2(), se.align,
+ n.children[0]);
break;
}
default:
@@ -117,7 +119,10 @@ struct LoadStoreTracking {
}
}
- void LoadStore(uint64_t offset, Opcode opc, Type type, Address align,
+ void LoadStore(uint64_t offset,
+ Opcode opc,
+ Type type,
+ Address align,
const Node& addr_exp) {
auto byte_size = opc.GetMemorySize();
type = GetMemoryType(type, opc);
@@ -131,10 +136,8 @@ struct LoadStoreTracking {
auto& access = var.accesses[offset];
// Check if previous access at this offset (if any) is of same size
// and type (see Checklayouts below).
- if (access.byte_size &&
- ((access.byte_size != byte_size) ||
- (access.type != type) ||
- (access.align != align)))
+ if (access.byte_size && ((access.byte_size != byte_size) ||
+ (access.type != type) || (access.align != align)))
access.is_uniform = false;
// Also exclude weird alignment accesses from structs.
if (!opc.IsNaturallyAligned(align))
@@ -202,9 +205,7 @@ struct LoadStoreTracking {
}
std::string GenAlign(Address align, Opcode opc) const {
- return opc.IsNaturallyAligned(align)
- ? ""
- : cat("@", std::to_string(align));
+ return opc.IsNaturallyAligned(align) ? "" : cat("@", std::to_string(align));
}
std::string GenTypeDecl(const std::string& name) const {
@@ -215,7 +216,9 @@ struct LoadStoreTracking {
if (it->second.struct_layout) {
std::string s = "{ ";
for (auto& access : it->second.accesses) {
- if (access.second.idx) s += ", ";
+ if (access.second.idx) {
+ s += ", ";
+ }
s += IdxToName(access.second.idx);
s += ':';
s += GetDecompTypeName(access.second.type);
@@ -243,7 +246,7 @@ struct LoadStoreTracking {
}
if (it->second.struct_layout) {
auto ait = it->second.accesses.find(offset);
- assert (ait != it->second.accesses.end());
+ assert(ait != it->second.accesses.end());
return IdxToName(ait->second.idx);
}
// Not a struct, see if it is a typed pointer.
@@ -253,9 +256,7 @@ struct LoadStoreTracking {
return "";
}
- void Clear() {
- vars.clear();
- }
+ void Clear() { vars.clear(); }
std::map<std::string, LSVar> vars;
};
diff --git a/src/decompiler-naming.h b/src/decompiler-naming.h
index 6f348317..155da009 100644
--- a/src/decompiler-naming.h
+++ b/src/decompiler-naming.h
@@ -23,7 +23,8 @@
namespace wabt {
-inline void RenameToIdentifier(std::string& name, Index i,
+inline void RenameToIdentifier(std::string& name,
+ Index i,
BindingHash& bh,
const std::set<string_view>* filter) {
// Filter out non-identifier characters, and try to reduce the size of
@@ -103,8 +104,9 @@ inline void RenameToIdentifier(std::string& name, Index i,
bh.emplace(s, Binding(i));
}
-template<typename T>
-void RenameToIdentifiers(std::vector<T*>& things, BindingHash& bh,
+template <typename T>
+void RenameToIdentifiers(std::vector<T*>& things,
+ BindingHash& bh,
const std::set<string_view>* filter) {
Index i = 0;
for (auto thing : things) {
diff --git a/src/decompiler.cc b/src/decompiler.cc
index 25fd75a1..1dd28868 100644
--- a/src/decompiler.cc
+++ b/src/decompiler.cc
@@ -64,12 +64,11 @@ struct Decompiler {
// but not if it is the reverse.
Precedence precedence;
- Value(std::vector<std::string>&& v, Precedence p)
- : v(v), precedence(p) {}
+ Value(std::vector<std::string>&& v, Precedence p) : v(v), precedence(p) {}
size_t width() {
size_t w = 0;
- for (auto &s : v) {
+ for (auto& s : v) {
w = std::max(w, s.size());
}
return w;
@@ -90,9 +89,7 @@ struct Decompiler {
return s;
}
- std::string Indent(size_t amount) {
- return std::string(amount, ' ');
- }
+ std::string Indent(size_t amount) { return std::string(amount, ' '); }
std::string OpcodeToToken(Opcode opcode) {
std::string s = opcode.GetDecomp();
@@ -100,7 +97,7 @@ struct Decompiler {
return s;
}
- void IndentValue(Value &val, size_t amount, string_view first_indent) {
+ void IndentValue(Value& val, size_t amount, string_view first_indent) {
auto indent = Indent(amount);
for (auto& stat : val.v) {
auto is = (&stat != &val.v[0] || first_indent.empty())
@@ -110,10 +107,12 @@ struct Decompiler {
}
}
- Value WrapChild(Value &child, string_view prefix, string_view postfix,
+ Value WrapChild(Value& child,
+ string_view prefix,
+ string_view postfix,
Precedence precedence) {
auto width = prefix.size() + postfix.size() + child.width();
- auto &v = child.v;
+ auto& v = child.v;
if (width < target_exp_width ||
(prefix.size() <= indent_amount && postfix.size() <= indent_amount)) {
if (v.size() == 1) {
@@ -135,15 +134,19 @@ struct Decompiler {
return std::move(child);
}
- void BracketIfNeeded(Value &val, Precedence parent_precedence) {
+ void BracketIfNeeded(Value& val, Precedence parent_precedence) {
if (parent_precedence < val.precedence ||
(parent_precedence == val.precedence &&
- Associative(parent_precedence))) return;
+ Associative(parent_precedence))) {
+ return;
+ }
val = WrapChild(val, "(", ")", Precedence::Atomic);
}
- Value WrapBinary(std::vector<Value>& args, string_view infix,
- bool indent_right, Precedence precedence) {
+ Value WrapBinary(std::vector<Value>& args,
+ string_view infix,
+ bool indent_right,
+ Precedence precedence) {
assert(args.size() == 2);
auto& left = args[0];
auto& right = args[1];
@@ -153,18 +156,22 @@ struct Decompiler {
if (width < target_exp_width && left.v.size() == 1 && right.v.size() == 1) {
return Value{{cat(left.v[0], " ", infix, " ", right.v[0])}, precedence};
} else {
- Value bin { {}, precedence };
+ Value bin{{}, precedence};
std::move(left.v.begin(), left.v.end(), std::back_inserter(bin.v));
bin.v.back().append(" ", 1);
bin.v.back().append(infix.data(), infix.size());
- if (indent_right) IndentValue(right, indent_amount, {});
+ if (indent_right) {
+ IndentValue(right, indent_amount, {});
+ }
std::move(right.v.begin(), right.v.end(), std::back_inserter(bin.v));
return bin;
}
}
- Value WrapNAry(std::vector<Value>& args, string_view prefix,
- string_view postfix, Precedence precedence) {
+ Value WrapNAry(std::vector<Value>& args,
+ string_view prefix,
+ string_view postfix,
+ Precedence precedence) {
size_t total_width = 0;
size_t max_width = 0;
bool multiline = false;
@@ -188,18 +195,21 @@ struct Decompiler {
return Value{{std::move(s)}, precedence};
} else {
// Multi-line.
- Value ml { {}, precedence };
+ Value ml{{}, precedence};
auto ident_with_name = max_width + prefix.size() < target_exp_width;
size_t i = 0;
for (auto& child : args) {
IndentValue(child, ident_with_name ? prefix.size() : indent_amount,
- !i && ident_with_name ? prefix : string_view {});
- if (i < args.size() - 1) child.v.back() += ",";
- std::move(child.v.begin(), child.v.end(),
- std::back_inserter(ml.v));
+ !i && ident_with_name ? prefix : string_view{});
+ if (i < args.size() - 1) {
+ child.v.back() += ",";
+ }
+ std::move(child.v.begin(), child.v.end(), std::back_inserter(ml.v));
i++;
}
- if (!ident_with_name) ml.v.insert(ml.v.begin(), std::string(prefix));
+ if (!ident_with_name) {
+ ml.v.insert(ml.v.begin(), std::string(prefix));
+ }
ml.v.back() += postfix;
return ml;
}
@@ -210,12 +220,15 @@ struct Decompiler {
return name[0] == '$' ? name.substr(1) : name;
}
- template<ExprType T> Value Get(const VarExpr<T>& ve) {
+ template <ExprType T>
+ Value Get(const VarExpr<T>& ve) {
return Value{{std::string(VarName(ve.var.name()))}, Precedence::Atomic};
}
- template<ExprType T> Value Set(Value& child, const VarExpr<T>& ve) {
- return WrapChild(child, VarName(ve.var.name()) + " = ", "", Precedence::Assign);
+ template <ExprType T>
+ Value Set(Value& child, const VarExpr<T>& ve) {
+ return WrapChild(child, VarName(ve.var.name()) + " = ", "",
+ Precedence::Assign);
}
std::string TempVarName(Index n) {
@@ -231,17 +244,25 @@ struct Decompiler {
struc.empty() ? GetDecompTypeName(t) : struc);
}
- bool ConstIntVal(const Expr* e, uint64_t &dest) {
+ bool ConstIntVal(const Expr* e, uint64_t& dest) {
dest = 0;
- if (!e || e->type() != ExprType::Const) return false;
+ if (!e || e->type() != ExprType::Const) {
+ return false;
+ }
auto& c = cast<ConstExpr>(e)->const_;
- if (c.type() != Type::I32 && c.type() != Type::I64) return false;
+ if (c.type() != Type::I32 && c.type() != Type::I64) {
+ return false;
+ }
dest = c.type() == Type::I32 ? c.u32() : c.u64();
return true;
}
- void LoadStore(Value &val, const Node& addr_exp, uint64_t offset,
- Opcode opc, Address align, Type op_type) {
+ void LoadStore(Value& val,
+ const Node& addr_exp,
+ uint64_t offset,
+ Opcode opc,
+ Address align,
+ Type op_type) {
bool append_type = true;
auto access = lst.GenAccess(offset, addr_exp);
if (!access.empty()) {
@@ -268,11 +289,10 @@ struct Decompiler {
uint64_t dat_base;
if (dat->offset.size() == 1 &&
ConstIntVal(&dat->offset.front(), dat_base) &&
- abs_base >= dat_base &&
- abs_base < dat_base + dat->data.size()) {
+ abs_base >= dat_base && abs_base < dat_base + dat->data.size()) {
// We are inside the range of this data segment!
// Turn expression into data_name[index]
- val = Value { { dat->name }, Precedence::Atomic };
+ val = Value{{dat->name}, Precedence::Atomic};
// The new offset is from the start of the data segment, instead of
// whatever it was.. this may be a different value from both the
// original const and offset!
@@ -285,8 +305,8 @@ struct Decompiler {
// cases, but the spec doesn't guarantee it, so we must
// have a backup syntax.
auto index = offset % align == 0
- ? std::to_string(offset / align)
- : cat(std::to_string(offset), "@", std::to_string(align));
+ ? std::to_string(offset / align)
+ : cat(std::to_string(offset), "@", std::to_string(align));
// Detect the very common case of (base + (index << 2))[0]:int etc.
// so we can instead do base[index]:int
// TODO: (index << 2) on the left of + occurs also.
@@ -296,12 +316,10 @@ struct Decompiler {
if (addr_exp.etype == ExprType::Binary) {
auto& pe = *cast<BinaryExpr>(addr_exp.e);
auto& shift_exp = addr_exp.children[1];
- if (pe.opcode == Opcode::I32Add &&
- shift_exp.etype == ExprType::Binary) {
+ if (pe.opcode == Opcode::I32Add && shift_exp.etype == ExprType::Binary) {
auto& se = *cast<BinaryExpr>(shift_exp.e);
auto& const_exp = shift_exp.children[1];
- if (se.opcode == Opcode::I32Shl &&
- const_exp.etype == ExprType::Const) {
+ if (se.opcode == Opcode::I32Shl && const_exp.etype == ExprType::Const) {
auto& ce = *cast<ConstExpr>(const_exp.e);
if (ce.const_.type() == Type::I32 &&
(1ULL << ce.const_.u32()) == align) {
@@ -327,9 +345,8 @@ struct Decompiler {
BracketIfNeeded(val, Precedence::Indexing);
val.v.back() += cat("[", index, "]");
if (append_type) {
- val.v.back() +=
- cat(":", GetDecompTypeName(GetMemoryType(op_type, opc)),
- lst.GenAlign(align, opc));
+ val.v.back() += cat(":", GetDecompTypeName(GetMemoryType(op_type, opc)),
+ lst.GenAlign(align, opc));
}
val.precedence = Precedence::Indexing;
}
@@ -344,20 +361,24 @@ struct Decompiler {
case NodeType::FlushToVars: {
std::string decls = "let ";
for (Index i = 0; i < n.u.var_count; i++) {
- if (i) decls += ", ";
+ if (i) {
+ decls += ", ";
+ }
decls += TempVarName(n.u.var_start + i);
}
decls += " = ";
return WrapNAry(args, decls, "", Precedence::Assign);
}
case NodeType::FlushedVar: {
- return Value { { TempVarName(n.u.var_start) }, Precedence::Atomic };
+ return Value{{TempVarName(n.u.var_start)}, Precedence::Atomic};
}
case NodeType::Statements: {
- Value stats { {}, Precedence::None };
+ Value stats{{}, Precedence::None};
for (size_t i = 0; i < n.children.size(); i++) {
auto& s = args[i].v.back();
- if (s.back() != '}' && s.back() != ':') s += ';';
+ if (s.back() != '}' && s.back() != ':') {
+ s += ';';
+ }
std::move(args[i].v.begin(), args[i].v.end(),
std::back_inserter(stats.v));
}
@@ -368,10 +389,9 @@ struct Decompiler {
}
case NodeType::Decl: {
cur_ast->vars_defined[n.u.var->name()].defined = true;
- return Value{
- {"var " + LocalDecl(std::string(n.u.var->name()),
- cur_func->GetLocalType(*n.u.var))},
- Precedence::None};
+ return Value{{"var " + LocalDecl(std::string(n.u.var->name()),
+ cur_func->GetLocalType(*n.u.var))},
+ Precedence::None};
}
case NodeType::DeclInit: {
if (cur_ast->vars_defined[n.u.var->name()].defined) {
@@ -379,13 +399,12 @@ struct Decompiler {
return WrapChild(args[0], cat(VarName(n.u.var->name()), " = "), "",
Precedence::None);
} else {
- return WrapChild(
- args[0],
- cat("var ",
- LocalDecl(std::string(n.u.var->name()),
- cur_func->GetLocalType(*n.u.var)),
- " = "),
- "", Precedence::None);
+ return WrapChild(args[0],
+ cat("var ",
+ LocalDecl(std::string(n.u.var->name()),
+ cur_func->GetLocalType(*n.u.var)),
+ " = "),
+ "", Precedence::None);
}
}
case NodeType::Expr:
@@ -460,7 +479,7 @@ struct Decompiler {
}
case ExprType::Unary: {
auto& ue = *cast<UnaryExpr>(n.e);
- //BracketIfNeeded(stack.back());
+ // BracketIfNeeded(stack.back());
// TODO: also version without () depending on precedence.
return WrapChild(args[0], OpcodeToToken(ue.opcode) + "(", ")",
Precedence::Atomic);
@@ -479,7 +498,7 @@ struct Decompiler {
}
case ExprType::If: {
auto ife = cast<IfExpr>(n.e);
- Value *elsep = nullptr;
+ Value* elsep = nullptr;
if (!ife->false_.empty()) {
elsep = &args[2];
}
@@ -501,7 +520,8 @@ struct Decompiler {
if (elsep) {
ifs.v.push_back("} else {");
IndentValue(*elsep, indent_amount, {});
- std::move(elsep->v.begin(), elsep->v.end(), std::back_inserter(ifs.v));
+ std::move(elsep->v.begin(), elsep->v.end(),
+ std::back_inserter(ifs.v));
}
ifs.v.push_back("}");
ifs.precedence = Precedence::If;
@@ -516,14 +536,13 @@ struct Decompiler {
case ExprType::Block: {
auto& val = args[0];
val.v.push_back(
- cat("label ", VarName(cast<BlockExpr>(n.e)->block.label), ":"));
+ cat("label ", VarName(cast<BlockExpr>(n.e)->block.label), ":"));
// If this block is part of a larger statement scope, it doesn't
// need its own indenting, but if its part of an exp we wrap it in {}.
- if (parent && parent->ntype != NodeType::Statements
- && parent->etype != ExprType::Block
- && parent->etype != ExprType::Loop
- && (parent->etype != ExprType::If ||
- &parent->children[0] == &n)) {
+ if (parent && parent->ntype != NodeType::Statements &&
+ parent->etype != ExprType::Block &&
+ parent->etype != ExprType::Loop &&
+ (parent->etype != ExprType::If || &parent->children[0] == &n)) {
IndentValue(val, indent_amount, {});
val.v.insert(val.v.begin(), "{");
val.v.push_back("}");
@@ -549,8 +568,8 @@ struct Decompiler {
case ExprType::BrIf: {
auto bie = cast<BrIfExpr>(n.e);
auto jmp = n.u.lt == LabelType::Loop ? "continue" : "goto";
- return WrapChild(args[0], "if (", cat(") ", jmp, " ",
- VarName(bie->var.name())),
+ return WrapChild(args[0], "if (",
+ cat(") ", jmp, " ", VarName(bie->var.name())),
Precedence::None);
}
case ExprType::Return: {
@@ -576,7 +595,7 @@ struct Decompiler {
case ExprType::BrTable: {
auto bte = cast<BrTableExpr>(n.e);
std::string ts = "br_table[";
- for (auto &v : bte->targets) {
+ for (auto& v : bte->targets) {
ts += VarName(v.name());
ts += ", ";
}
@@ -659,7 +678,7 @@ struct Decompiler {
return is_import;
}
- std::string InitExp(const ExprList &el) {
+ std::string InitExp(const ExprList& el) {
assert(!el.empty());
AST ast(mc, nullptr);
ast.Construct(el, 1, 0, false);
@@ -669,7 +688,7 @@ struct Decompiler {
}
// FIXME: Merge with WatWriter::WriteQuotedData somehow.
- std::string BinaryToString(const std::vector<uint8_t> &in) {
+ std::string BinaryToString(const std::vector<uint8_t>& in) {
std::string s = "\"";
size_t line_start = 0;
static const char s_hexdigits[] = "0123456789abcdef";
diff --git a/src/decompiler.h b/src/decompiler.h
index 89bfe78d..e52a8215 100644
--- a/src/decompiler.h
+++ b/src/decompiler.h
@@ -24,8 +24,7 @@ namespace wabt {
struct Module;
class Stream;
-struct DecompileOptions {
-};
+struct DecompileOptions {};
void RenameAll(Module&);
diff --git a/src/error-formatter.h b/src/error-formatter.h
index cd2ed912..7d28a8f9 100644
--- a/src/error-formatter.h
+++ b/src/error-formatter.h
@@ -18,8 +18,8 @@
#define WABT_ERROR_FORMATTER_H_
#include <cstdio>
-#include <string>
#include <memory>
+#include <string>
#include "src/color.h"
#include "src/error.h"
diff --git a/src/expr-visitor.cc b/src/expr-visitor.cc
index b50400c4..d346f3b7 100644
--- a/src/expr-visitor.cc
+++ b/src/expr-visitor.cc
@@ -378,7 +378,6 @@ Result ExprVisitor::HandleDefaultState(Expr* expr) {
CHECK_RESULT(delegate_->OnStoreExpr(cast<StoreExpr>(expr)));
break;
-
case ExprType::Throw:
CHECK_RESULT(delegate_->OnThrowExpr(cast<ThrowExpr>(expr)));
break;
diff --git a/src/generate-names.cc b/src/generate-names.cc
index 5f99f0e8..35f136c3 100644
--- a/src/generate-names.cc
+++ b/src/generate-names.cc
@@ -52,9 +52,7 @@ class NameGenerator : public ExprVisitor::DelegateNop {
std::string* out_str);
// Like GenerateName, but only generates a name if |out_str| is empty.
- void MaybeGenerateName(const char* prefix,
- Index index,
- std::string* out_str);
+ void MaybeGenerateName(const char* prefix, Index index, std::string* out_str);
// Generate a name via GenerateName and bind it to the given binding hash. If
// the name already exists, the name will be disambiguated until it can be
@@ -108,8 +106,7 @@ class NameGenerator : public ExprVisitor::DelegateNop {
NameOpts opts_;
};
-NameGenerator::NameGenerator(NameOpts opts)
- : visitor_(this), opts_(opts) {}
+NameGenerator::NameGenerator(NameOpts opts) : visitor_(this), opts_(opts) {}
// static
bool NameGenerator::HasName(const std::string& str) {
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>
diff --git a/src/intrusive-list.h b/src/intrusive-list.h
index 7d9611a7..74161561 100644
--- a/src/intrusive-list.h
+++ b/src/intrusive-list.h
@@ -320,8 +320,8 @@ inline typename intrusive_list<T>::iterator intrusive_list<T>::end() noexcept {
}
template <typename T>
-inline typename intrusive_list<T>::const_iterator intrusive_list<T>::end() const
- noexcept {
+inline typename intrusive_list<T>::const_iterator intrusive_list<T>::end()
+ const noexcept {
return const_iterator(*this, nullptr);
}
@@ -374,8 +374,8 @@ intrusive_list<T>::crend() const noexcept {
}
template <typename T>
-inline typename intrusive_list<T>::size_type intrusive_list<T>::size() const
- noexcept {
+inline typename intrusive_list<T>::size_type intrusive_list<T>::size()
+ const noexcept {
return size_;
}
diff --git a/src/ir-util.cc b/src/ir-util.cc
index 9b664611..959f0937 100644
--- a/src/ir-util.cc
+++ b/src/ir-util.cc
@@ -30,8 +30,8 @@
#include "src/cast.h"
#include "src/common.h"
#include "src/expr-visitor.h"
-#include "src/ir.h"
#include "src/ir-util.h"
+#include "src/ir.h"
#include "src/literal.h"
#include "src/stream.h"
@@ -102,53 +102,52 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const {
case ExprType::Binary:
case ExprType::Compare:
case ExprType::TableGrow:
- return { 2, 1 };
+ return {2, 1};
case ExprType::AtomicStore:
case ExprType::Store:
case ExprType::TableSet:
- return { 2, 0 };
+ return {2, 0};
case ExprType::Block:
- return { 0, cast<BlockExpr>(&expr)->block.decl.sig.GetNumResults() };
+ return {0, cast<BlockExpr>(&expr)->block.decl.sig.GetNumResults()};
case ExprType::Br:
- return { GetLabelArity(cast<BrExpr>(&expr)->var), 1, true };
+ return {GetLabelArity(cast<BrExpr>(&expr)->var), 1, true};
case ExprType::BrIf: {
Index arity = GetLabelArity(cast<BrIfExpr>(&expr)->var);
- return { arity + 1, arity };
+ return {arity + 1, arity};
}
case ExprType::BrTable:
- return { GetLabelArity(cast<BrTableExpr>(&expr)->default_target) + 1, 1,
- true };
+ return {GetLabelArity(cast<BrTableExpr>(&expr)->default_target) + 1, 1,
+ true};
case ExprType::Call: {
const Var& var = cast<CallExpr>(&expr)->var;
- return { GetFuncParamCount(var), GetFuncResultCount(var) };
+ return {GetFuncParamCount(var), GetFuncResultCount(var)};
}
case ExprType::ReturnCall: {
const Var& var = cast<ReturnCallExpr>(&expr)->var;
- return { GetFuncParamCount(var), GetFuncResultCount(var), true };
+ return {GetFuncParamCount(var), GetFuncResultCount(var), true};
}
case ExprType::CallIndirect: {
const auto* ci_expr = cast<CallIndirectExpr>(&expr);
- return { ci_expr->decl.GetNumParams() + 1,
- ci_expr->decl.GetNumResults() };
+ return {ci_expr->decl.GetNumParams() + 1, ci_expr->decl.GetNumResults()};
}
case ExprType::CallRef: {
const Var& var = cast<CallRefExpr>(&expr)->function_type_index;
- return { GetFuncParamCount(var) + 1, GetFuncResultCount(var) };
+ return {GetFuncParamCount(var) + 1, GetFuncResultCount(var)};
}
case ExprType::ReturnCallIndirect: {
const auto* rci_expr = cast<ReturnCallIndirectExpr>(&expr);
- return { rci_expr->decl.GetNumParams() + 1,
- rci_expr->decl.GetNumResults(), true };
+ return {rci_expr->decl.GetNumParams() + 1, rci_expr->decl.GetNumResults(),
+ true};
}
case ExprType::Const:
@@ -158,15 +157,15 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const {
case ExprType::TableSize:
case ExprType::RefNull:
case ExprType::RefFunc:
- return { 0, 1 };
+ return {0, 1};
case ExprType::Unreachable:
- return { 0, 1, true };
+ return {0, 1, true};
case ExprType::DataDrop:
case ExprType::ElemDrop:
case ExprType::AtomicFence:
- return { 0, 0 };
+ return {0, 0};
case ExprType::MemoryInit:
case ExprType::TableInit:
@@ -174,7 +173,7 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const {
case ExprType::MemoryCopy:
case ExprType::TableCopy:
case ExprType::TableFill:
- return { 3, 0 };
+ return {3, 0};
case ExprType::AtomicLoad:
case ExprType::Convert:
@@ -186,34 +185,33 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const {
case ExprType::RefIsNull:
case ExprType::LoadSplat:
case ExprType::LoadZero:
- return { 1, 1 };
+ return {1, 1};
case ExprType::Drop:
case ExprType::GlobalSet:
case ExprType::LocalSet:
- return { 1, 0 };
+ return {1, 0};
case ExprType::If:
- return { 1, cast<IfExpr>(&expr)->true_.decl.sig.GetNumResults() };
+ return {1, cast<IfExpr>(&expr)->true_.decl.sig.GetNumResults()};
case ExprType::Loop:
- return { 0, cast<LoopExpr>(&expr)->block.decl.sig.GetNumResults() };
+ return {0, cast<LoopExpr>(&expr)->block.decl.sig.GetNumResults()};
case ExprType::Nop:
- return { 0, 0 };
+ return {0, 0};
case ExprType::Return:
- return
- { static_cast<Index>(current_func_->decl.sig.result_types.size()), 1,
- true };
+ return {static_cast<Index>(current_func_->decl.sig.result_types.size()),
+ 1, true};
case ExprType::Rethrow:
- return { 0, 0, true };
+ return {0, 0, true};
case ExprType::AtomicRmwCmpxchg:
case ExprType::AtomicWait:
case ExprType::Select:
- return { 3, 1 };
+ return {3, 1};
case ExprType::Throw: {
auto throw_ = cast<ThrowExpr>(&expr);
@@ -221,14 +219,14 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const {
if (Tag* tag = module.GetTag(throw_->var)) {
operand_count = tag->decl.sig.param_types.size();
}
- return { operand_count, 0, true };
+ return {operand_count, 0, true};
}
case ExprType::Try:
- return { 0, cast<TryExpr>(&expr)->block.decl.sig.GetNumResults() };
+ return {0, cast<TryExpr>(&expr)->block.decl.sig.GetNumResults()};
case ExprType::Ternary:
- return { 3, 1 };
+ return {3, 1};
case ExprType::SimdLaneOp: {
const Opcode opcode = cast<SimdLaneOpExpr>(&expr)->opcode;
@@ -241,7 +239,7 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const {
case Opcode::I64X2ExtractLane:
case Opcode::F32X4ExtractLane:
case Opcode::F64X2ExtractLane:
- return { 1, 1 };
+ return {1, 1};
case Opcode::I8X16ReplaceLane:
case Opcode::I16X8ReplaceLane:
@@ -249,23 +247,23 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const {
case Opcode::I64X2ReplaceLane:
case Opcode::F32X4ReplaceLane:
case Opcode::F64X2ReplaceLane:
- return { 2, 1 };
+ return {2, 1};
default:
fprintf(stderr, "Invalid Opcode for expr type: %s\n",
GetExprTypeName(expr));
assert(0);
- return { 0, 0 };
+ return {0, 0};
}
}
case ExprType::SimdLoadLane:
case ExprType::SimdStoreLane: {
- return { 2, 1 };
+ return {2, 1};
}
case ExprType::SimdShuffleOp:
- return { 2, 1 };
+ return {2, 1};
}
WABT_UNREACHABLE;
diff --git a/src/ir-util.h b/src/ir-util.h
index 226e81aa..db9cf5b4 100644
--- a/src/ir-util.h
+++ b/src/ir-util.h
@@ -39,7 +39,7 @@ struct Label {
};
struct ModuleContext {
- ModuleContext(const Module &module) : module(module) {}
+ ModuleContext(const Module& module) : module(module) {}
Index GetLabelStackSize() const { return label_stack_.size(); }
const Label* GetLabel(const Var& var) const;
@@ -61,11 +61,12 @@ struct ModuleContext {
Index nreturns;
bool unreachable;
Arities(Index na, Index nr, bool ur = false)
- : nargs(na), nreturns(nr), unreachable(ur) {}
+ : nargs(na), nreturns(nr), unreachable(ur) {}
};
Arities GetExprArity(const Expr& expr) const;
- const Module &module;
+ const Module& module;
+
private:
const Func* current_func_ = nullptr;
std::vector<Label> label_stack_;
diff --git a/src/ir.cc b/src/ir.cc
index bace825b..3af95685 100644
--- a/src/ir.cc
+++ b/src/ir.cc
@@ -25,68 +25,68 @@
namespace {
const char* ExprTypeName[] = {
- "AtomicFence",
- "AtomicLoad",
- "AtomicRmw",
- "AtomicRmwCmpxchg",
- "AtomicStore",
- "AtomicNotify",
- "AtomicWait",
- "Binary",
- "Block",
- "Br",
- "BrIf",
- "BrTable",
- "Call",
- "CallIndirect",
- "CallRef",
- "Compare",
- "Const",
- "Convert",
- "Drop",
- "GlobalGet",
- "GlobalSet",
- "If",
- "Load",
- "LocalGet",
- "LocalSet",
- "LocalTee",
- "Loop",
- "MemoryCopy",
- "DataDrop",
- "MemoryFill",
- "MemoryGrow",
- "MemoryInit",
- "MemorySize",
- "Nop",
- "RefIsNull",
- "RefFunc",
- "RefNull",
- "Rethrow",
- "Return",
- "ReturnCall",
- "ReturnCallIndirect",
- "Select",
- "SimdLaneOp",
- "SimdLoadLane",
- "SimdStoreLane",
- "SimdShuffleOp",
- "LoadSplat",
- "LoadZero",
- "Store",
- "TableCopy",
- "ElemDrop",
- "TableInit",
- "TableGet",
- "TableGrow",
- "TableSize",
- "TableSet",
- "TableFill",
- "Ternary",
- "Throw",
- "Try",
- "Unary",
- "Unreachable",
+ "AtomicFence",
+ "AtomicLoad",
+ "AtomicRmw",
+ "AtomicRmwCmpxchg",
+ "AtomicStore",
+ "AtomicNotify",
+ "AtomicWait",
+ "Binary",
+ "Block",
+ "Br",
+ "BrIf",
+ "BrTable",
+ "Call",
+ "CallIndirect",
+ "CallRef",
+ "Compare",
+ "Const",
+ "Convert",
+ "Drop",
+ "GlobalGet",
+ "GlobalSet",
+ "If",
+ "Load",
+ "LocalGet",
+ "LocalSet",
+ "LocalTee",
+ "Loop",
+ "MemoryCopy",
+ "DataDrop",
+ "MemoryFill",
+ "MemoryGrow",
+ "MemoryInit",
+ "MemorySize",
+ "Nop",
+ "RefIsNull",
+ "RefFunc",
+ "RefNull",
+ "Rethrow",
+ "Return",
+ "ReturnCall",
+ "ReturnCallIndirect",
+ "Select",
+ "SimdLaneOp",
+ "SimdLoadLane",
+ "SimdStoreLane",
+ "SimdShuffleOp",
+ "LoadSplat",
+ "LoadZero",
+ "Store",
+ "TableCopy",
+ "ElemDrop",
+ "TableInit",
+ "TableGet",
+ "TableGrow",
+ "TableSize",
+ "TableSet",
+ "TableFill",
+ "Ternary",
+ "Throw",
+ "Try",
+ "Unary",
+ "Unreachable",
};
} // end of anonymous namespace
@@ -197,7 +197,7 @@ Index LocalTypes::size() const {
Type LocalTypes::operator[](Index i) const {
Index count = 0;
- for (auto decl: decls_) {
+ for (auto decl : decls_) {
if (i < count + decl.second) {
return decl.first;
}
@@ -692,5 +692,4 @@ uint8_t DataSegment::GetFlags(const Module* module) const {
return flags;
}
-
} // namespace wabt
diff --git a/src/ir.h b/src/ir.h
index 52baab39..d69100dc 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -53,8 +53,14 @@ struct Var {
bool is_index() const { return type_ == VarType::Index; }
bool is_name() const { return type_ == VarType::Name; }
- Index index() const { assert(is_index()); return index_; }
- const std::string& name() const { assert(is_name()); return name_; }
+ Index index() const {
+ assert(is_index());
+ return index_;
+ }
+ const std::string& name() const {
+ assert(is_name());
+ return name_;
+ }
void set_index(Index);
void set_name(std::string&&);
@@ -95,7 +101,10 @@ struct Const {
}
Type type() const { return type_; }
- Type lane_type() const { assert(type_ == Type::V128); return lane_type_; }
+ Type lane_type() const {
+ assert(type_ == Type::V128);
+ return lane_type_;
+ }
int lane_count() const {
switch (lane_type()) {
@@ -117,7 +126,9 @@ struct Const {
v128 vec128() const { return data_; }
template <typename T>
- T v128_lane(int lane) const { return data_.To<T>(lane); }
+ T v128_lane(int lane) const {
+ return data_.To<T>(lane);
+ }
void set_u32(uint32_t x) { From(Type::I32, x); }
void set_u64(uint64_t x) { From(Type::I64, x); }
@@ -132,11 +143,17 @@ struct Const {
void set_v128_f64(int lane, uint64_t x) { set_v128_lane(lane, Type::F64, x); }
// Only used for expectations. (e.g. wast assertions)
- void set_f32(ExpectedNan nan) { set_f32(0); set_expected_nan(0, nan); }
- void set_f64(ExpectedNan nan) { set_f64(0); set_expected_nan(0, nan); }
- void set_funcref() { From<uintptr_t>(Type::FuncRef, 0); }
+ void set_f32(ExpectedNan nan) {
+ set_f32(0);
+ set_expected_nan(0, nan);
+ }
+ void set_f64(ExpectedNan nan) {
+ set_f64(0);
+ set_expected_nan(0, nan);
+ }
+ void set_funcref() { From<uintptr_t>(Type::FuncRef, 0); }
void set_externref(uintptr_t x) { From(Type::ExternRef, x); }
- void set_null(Type type) { From<uintptr_t>(type, kRefNullBits); }
+ void set_null(Type type) { From<uintptr_t>(type, kRefNullBits); }
bool is_expected_nan(int lane = 0) const {
return expected_nan(lane) != ExpectedNan::None;
@@ -178,7 +195,7 @@ struct Const {
}
Type type_;
- Type lane_type_; // Only valid if type_ == Type::V128.
+ Type lane_type_; // Only valid if type_ == Type::V128.
v128 data_;
ExpectedNan nan_[4];
};
@@ -385,11 +402,7 @@ struct Catch {
};
typedef std::vector<Catch> CatchVector;
-enum class TryKind {
- Plain,
- Catch,
- Delegate
-};
+enum class TryKind { Plain, Catch, Delegate };
class Expr : public intrusive_list_base<Expr> {
public:
@@ -614,7 +627,7 @@ class CallIndirectExpr : public ExprMixin<ExprType::CallIndirect> {
class ReturnCallIndirectExpr : public ExprMixin<ExprType::ReturnCallIndirect> {
public:
- explicit ReturnCallIndirectExpr(const Location &loc = Location())
+ explicit ReturnCallIndirectExpr(const Location& loc = Location())
: ExprMixin<ExprType::ReturnCallIndirect>(loc) {}
FuncDeclaration decl;
@@ -623,7 +636,7 @@ class ReturnCallIndirectExpr : public ExprMixin<ExprType::ReturnCallIndirect> {
class CallRefExpr : public ExprMixin<ExprType::CallRef> {
public:
- explicit CallRefExpr(const Location &loc = Location())
+ explicit CallRefExpr(const Location& loc = Location())
: ExprMixin<ExprType::CallRef>(loc) {}
// This field is setup only during Validate phase,
diff --git a/src/literal.cc b/src/literal.cc
index 0061772e..615d8cb5 100644
--- a/src/literal.cc
+++ b/src/literal.cc
@@ -649,7 +649,9 @@ Result ParseInt64(const char* s,
namespace {
uint32_t AddWithCarry(uint32_t x, uint32_t y, uint32_t* carry) {
// Increments *carry if the addition overflows, otherwise leaves carry alone.
- if ((0xffffffff - x) < y) ++*carry;
+ if ((0xffffffff - x) < y) {
+ ++*carry;
+ }
return x + y;
}
@@ -674,11 +676,9 @@ void Mul10(v128* v) {
v->set_u32(2, AddWithCarry(v->u32(2), carry_into_v2, &carry_into_v3));
v->set_u32(3, v->u32(3) * 10 + carry_into_v3);
}
-}
+} // namespace
-Result ParseUint128(const char* s,
- const char* end,
- v128* out) {
+Result ParseUint128(const char* s, const char* end, v128* out) {
if (s == end) {
return Result::Error;
}
@@ -801,7 +801,7 @@ void WriteUint128(char* buffer, size_t size, v128 bits) {
for (int i = 3; i != 0; --i) {
digits = remainder / 10;
- remainder = ((remainder - digits * 10) << 32) + bits.u32(i-1);
+ remainder = ((remainder - digits * 10) << 32) + bits.u32(i - 1);
bits.set_u32(i, digits);
}
@@ -822,8 +822,7 @@ void WriteUint128(char* buffer, size_t size, v128 bits) {
len = size - 1;
}
std::reverse_copy(reversed_buffer + truncated_tail,
- reversed_buffer + len + truncated_tail,
- buffer);
+ reversed_buffer + len + truncated_tail, buffer);
buffer[len] = '\0';
}
diff --git a/src/opcode-code-table.h b/src/opcode-code-table.h
index b223e161..3adb478d 100644
--- a/src/opcode-code-table.h
+++ b/src/opcode-code-table.h
@@ -17,8 +17,8 @@
#ifndef WABT_OPCODE_CODE_TABLE_H_
#define WABT_OPCODE_CODE_TABLE_H_
-#include <stdlib.h>
#include <stdint.h>
+#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
diff --git a/src/opcode.cc b/src/opcode.cc
index 6a70eb4f..cfa23f1d 100644
--- a/src/opcode.cc
+++ b/src/opcode.cc
@@ -33,7 +33,7 @@ Opcode::Info Opcode::infos_[] = {
};
#define WABT_OPCODE(rtype, type1, type2, type3, mem_size, prefix, code, Name, \
- text, decomp) \
+ text, decomp) \
/* static */ Opcode Opcode::Name##_Opcode(Opcode::Name);
#include "src/opcode.def"
#undef WABT_OPCODE
diff --git a/src/opcode.h b/src/opcode.h
index 94cd4cb8..486af52a 100644
--- a/src/opcode.h
+++ b/src/opcode.h
@@ -20,8 +20,8 @@
#include <vector>
#include "src/common.h"
-#include "src/opcode-code-table.h"
#include "src/leb128.h"
+#include "src/opcode-code-table.h"
namespace wabt {
@@ -176,7 +176,6 @@ inline Opcode Opcode::FromCode(uint8_t prefix, uint32_t code) {
return Opcode(EncodeInvalidOpcode(prefix_code));
}
-
} // namespace wabt
#endif // WABT_OPCODE_H_
diff --git a/src/option-parser.cc b/src/option-parser.cc
index d6a38ae8..cf11d458 100644
--- a/src/option-parser.cc
+++ b/src/option-parser.cc
@@ -50,7 +50,6 @@ OptionParser::OptionParser(const char* program_name, const char* description)
: program_name_(program_name),
description_(description),
on_error_([this](const std::string& message) { DefaultError(message); }) {
-
// Add common options
AddOption("help", "Print this help message", [this]() {
PrintHelp();
diff --git a/src/resolve-names.cc b/src/resolve-names.cc
index 6b67a906..fd555779 100644
--- a/src/resolve-names.cc
+++ b/src/resolve-names.cc
@@ -45,7 +45,7 @@ class NameResolver : public ExprVisitor::DelegateNop {
Result OnCallIndirectExpr(CallIndirectExpr*) override;
Result OnCatchExpr(TryExpr*, Catch*) override;
Result OnDelegateExpr(TryExpr*) override;
- Result OnReturnCallExpr(ReturnCallExpr *) override;
+ Result OnReturnCallExpr(ReturnCallExpr*) override;
Result OnReturnCallIndirectExpr(ReturnCallIndirectExpr*) override;
Result OnGlobalGetExpr(GlobalGetExpr*) override;
Result OnGlobalSetExpr(GlobalSetExpr*) override;
@@ -117,9 +117,7 @@ class NameResolver : public ExprVisitor::DelegateNop {
};
NameResolver::NameResolver(Script* script, Errors* errors)
- : errors_(errors),
- script_(script),
- visitor_(this) {}
+ : errors_(errors), script_(script), visitor_(this) {}
} // end anonymous namespace
diff --git a/src/shared-validator.cc b/src/shared-validator.cc
index 0e77ffa0..b301ad09 100644
--- a/src/shared-validator.cc
+++ b/src/shared-validator.cc
@@ -1013,9 +1013,9 @@ Result SharedValidator::OnSimdLaneOp(const Location& loc,
}
Result SharedValidator::OnSimdLoadLane(const Location& loc,
- Opcode opcode,
- Address alignment,
- uint64_t value) {
+ Opcode opcode,
+ Address alignment,
+ uint64_t value) {
Result result = CheckInstr(opcode, loc);
MemoryType mt;
result |= CheckMemoryIndex(Var(0, loc), &mt);
diff --git a/src/shared-validator.h b/src/shared-validator.h
index 2bc18788..0f422a8b 100644
--- a/src/shared-validator.h
+++ b/src/shared-validator.h
@@ -155,8 +155,14 @@ class SharedValidator {
Result OnReturn(const Location&);
Result OnSelect(const Location&, Index result_count, Type* result_types);
Result OnSimdLaneOp(const Location&, Opcode, uint64_t lane_idx);
- Result OnSimdLoadLane(const Location&, Opcode, Address align, uint64_t lane_idx);
- Result OnSimdStoreLane(const Location&, Opcode, Address align, uint64_t lane_idx);
+ Result OnSimdLoadLane(const Location&,
+ Opcode,
+ Address align,
+ uint64_t lane_idx);
+ Result OnSimdStoreLane(const Location&,
+ Opcode,
+ Address align,
+ uint64_t lane_idx);
Result OnSimdShuffleOp(const Location&, Opcode, v128 lane_idx);
Result OnStore(const Location&, Opcode, Var memidx, Address align);
Result OnTableCopy(const Location&, Var dst_var, Var src_var);
@@ -268,7 +274,9 @@ class SharedValidator {
Result CheckDataSegmentIndex(Var data_segment_var);
Result CheckAlign(const Location&, Address align, Address natural_align);
- Result CheckAtomicAlign(const Location&, Address align, Address natural_align);
+ Result CheckAtomicAlign(const Location&,
+ Address align,
+ Address natural_align);
Result CheckBlockSignature(const Location&,
Opcode,
diff --git a/src/stream.cc b/src/stream.cc
index e52c51b9..cf6d17f2 100644
--- a/src/stream.cc
+++ b/src/stream.cc
@@ -255,7 +255,9 @@ FileStream::~FileStream() {
}
void FileStream::Flush() {
- if (file_) fflush(file_);
+ if (file_) {
+ fflush(file_);
+ }
}
Result FileStream::WriteDataImpl(size_t at, const void* data, size_t size) {
diff --git a/src/string-view.cc b/src/string-view.cc
index bb32410a..68d2a7a3 100644
--- a/src/string-view.cc
+++ b/src/string-view.cc
@@ -100,8 +100,8 @@ int string_view::compare(size_type pos1,
return substr(pos1, n1).compare(string_view(s, n2));
}
-string_view::size_type string_view::find(string_view s, size_type pos) const
- noexcept {
+string_view::size_type string_view::find(string_view s,
+ size_type pos) const noexcept {
pos = std::min(pos, size_);
const_iterator iter = std::search(begin() + pos, end(), s.begin(), s.end());
return iter == end() ? npos : iter - begin();
@@ -121,16 +121,16 @@ string_view::size_type string_view::find(const char* s, size_type pos) const {
return find(string_view(s), pos);
}
-string_view::size_type string_view::rfind(string_view s, size_type pos) const
- noexcept {
+string_view::size_type string_view::rfind(string_view s,
+ size_type pos) const noexcept {
pos = std::min(std::min(pos, size_ - s.size_) + s.size_, size_);
reverse_iterator iter = std::search(reverse_iterator(begin() + pos), rend(),
s.rbegin(), s.rend());
return iter == rend() ? npos : (rend() - iter - s.size_);
}
-string_view::size_type string_view::rfind(char c, size_type pos) const
- noexcept {
+string_view::size_type string_view::rfind(char c,
+ size_type pos) const noexcept {
return rfind(string_view(&c, 1), pos);
}
@@ -144,17 +144,16 @@ string_view::size_type string_view::rfind(const char* s, size_type pos) const {
return rfind(string_view(s), pos);
}
-string_view::size_type string_view::find_first_of(string_view s,
- size_type pos) const
- noexcept {
+string_view::size_type string_view::find_first_of(string_view s, size_type pos)
+ const noexcept {
pos = std::min(pos, size_);
const_iterator iter =
std::find_first_of(begin() + pos, end(), s.begin(), s.end());
return iter == end() ? npos : iter - begin();
}
-string_view::size_type string_view::find_first_of(char c, size_type pos) const
- noexcept {
+string_view::size_type string_view::find_first_of(char c, size_type pos)
+ const noexcept {
return find_first_of(string_view(&c, 1), pos);
}
@@ -177,8 +176,8 @@ string_view::size_type string_view::find_last_of(string_view s,
return iter == rend() ? npos : (rend() - iter - 1);
}
-string_view::size_type string_view::find_last_of(char c, size_type pos) const
- noexcept {
+string_view::size_type string_view::find_last_of(char c,
+ size_type pos) const noexcept {
return find_last_of(string_view(&c, 1), pos);
}
diff --git a/src/string-view.h b/src/string-view.h
index 534e675c..25cff41f 100644
--- a/src/string-view.h
+++ b/src/string-view.h
@@ -110,25 +110,25 @@ class string_view {
/*constexpr*/ size_type find(char c, size_type pos = 0) const noexcept;
/*constexpr*/ size_type find(const char* s, size_type pos, size_type n) const;
/*constexpr*/ size_type find(const char* s, size_type pos = 0) const;
- /*constexpr*/ size_type rfind(string_view s, size_type pos = npos) const
- noexcept;
+ /*constexpr*/ size_type rfind(string_view s,
+ size_type pos = npos) const noexcept;
/*constexpr*/ size_type rfind(char c, size_type pos = npos) const noexcept;
/*constexpr*/ size_type rfind(const char* s,
size_type pos,
size_type n) const;
/*constexpr*/ size_type rfind(const char* s, size_type pos = npos) const;
- /*constexpr*/ size_type find_first_of(string_view s, size_type pos = 0) const
- noexcept;
- /*constexpr*/ size_type find_first_of(char c, size_type pos = 0) const
- noexcept;
+ /*constexpr*/ size_type find_first_of(string_view s,
+ size_type pos = 0) const noexcept;
+ /*constexpr*/ size_type find_first_of(char c,
+ size_type pos = 0) const noexcept;
/*constexpr*/ size_type find_first_of(const char* s,
size_type pos,
size_type n) const;
/*constexpr*/ size_type find_first_of(const char* s, size_type pos = 0) const;
/*constexpr*/ size_type find_last_of(string_view s,
size_type pos = npos) const noexcept;
- /*constexpr*/ size_type find_last_of(char c, size_type pos = npos) const
- noexcept;
+ /*constexpr*/ size_type find_last_of(char c,
+ size_type pos = npos) const noexcept;
/*constexpr*/ size_type find_last_of(const char* s,
size_type pos,
size_type n) const;
@@ -219,25 +219,28 @@ inline std::string operator+(string_view x, const char* y) {
inline void cat_concatenate(std::string&) {}
-template<typename T, typename ...Ts>
+template <typename T, typename... Ts>
void cat_concatenate(std::string& s, const T& t, const Ts&... args) {
- s += t;
- cat_concatenate(s, args...);
+ s += t;
+ cat_concatenate(s, args...);
}
-inline size_t cat_compute_size() { return 0; }
+inline size_t cat_compute_size() {
+ return 0;
+}
-template<typename T, typename ...Ts>
+template <typename T, typename... Ts>
size_t cat_compute_size(const T& t, const Ts&... args) {
- return string_view(t).size() + cat_compute_size(args...);
+ return string_view(t).size() + cat_compute_size(args...);
}
// Is able to concatenate any combination of string/string_view/char*
-template<typename ...Ts> std::string cat(const Ts&... args) {
- std::string s;
- s.reserve(cat_compute_size(args...));
- cat_concatenate(s, args...);
- return s;
+template <typename... Ts>
+std::string cat(const Ts&... args) {
+ std::string s;
+ s.reserve(cat_compute_size(args...));
+ cat_concatenate(s, args...);
+ return s;
}
inline constexpr string_view::string_view() noexcept
@@ -252,8 +255,8 @@ inline string_view::string_view(const char* str)
inline constexpr string_view::string_view(const char* str, size_type len)
: data_(str), size_(len) {}
-inline constexpr string_view::const_iterator string_view::begin() const
- noexcept {
+inline constexpr string_view::const_iterator string_view::begin()
+ const noexcept {
return data_;
}
@@ -261,18 +264,18 @@ inline constexpr string_view::const_iterator string_view::end() const noexcept {
return data_ + size_;
}
-inline constexpr string_view::const_iterator string_view::cbegin() const
- noexcept {
+inline constexpr string_view::const_iterator string_view::cbegin()
+ const noexcept {
return data_;
}
-inline constexpr string_view::const_iterator string_view::cend() const
- noexcept {
+inline constexpr string_view::const_iterator string_view::cend()
+ const noexcept {
return data_ + size_;
}
-inline string_view::const_reverse_iterator string_view::rbegin() const
- noexcept {
+inline string_view::const_reverse_iterator string_view::rbegin()
+ const noexcept {
return const_reverse_iterator(end());
}
@@ -280,8 +283,8 @@ inline string_view::const_reverse_iterator string_view::rend() const noexcept {
return const_reverse_iterator(begin());
}
-inline string_view::const_reverse_iterator string_view::crbegin() const
- noexcept {
+inline string_view::const_reverse_iterator string_view::crbegin()
+ const noexcept {
return const_reverse_iterator(cend());
}
@@ -326,8 +329,8 @@ constexpr inline string_view::const_pointer string_view::data() const noexcept {
}
inline std::ostream& operator<<(std::ostream& os, string_view sv) {
- os.write(sv.data(), sv.size());
- return os;
+ os.write(sv.data(), sv.size());
+ return os;
}
} // namespace wabt
diff --git a/src/test-binary-reader.cc b/src/test-binary-reader.cc
index a96ccdb7..ee206013 100644
--- a/src/test-binary-reader.cc
+++ b/src/test-binary-reader.cc
@@ -16,8 +16,8 @@
#include "gtest/gtest.h"
-#include "src/binary-reader.h"
#include "src/binary-reader-nop.h"
+#include "src/binary-reader.h"
#include "src/leb128.h"
#include "src/opcode.h"
diff --git a/src/test-interp.cc b/src/test-interp.cc
index d207a8e6..245bc884 100644
--- a/src/test-interp.cc
+++ b/src/test-interp.cc
@@ -59,7 +59,6 @@ class InterpTest : public ::testing::Test {
Instance::Ptr inst_;
};
-
TEST_F(InterpTest, Empty) {
ASSERT_TRUE(mod_.empty());
ReadModule({0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00});
@@ -308,18 +307,18 @@ TEST_F(InterpTest, HostFunc_PingPong) {
0x0b, 0x01, 0x09, 0x00, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x10, 0x00, 0x0b,
});
- auto host_func = HostFunc::New(
- store_, FuncType{{ValueType::I32}, {ValueType::I32}},
- [&](Thread& thread, const Values& params, Values& results,
- Trap::Ptr* out_trap) -> Result {
- auto val = params[0].Get<u32>();
- if (val < 10) {
- return GetFuncExport(0)->Call(store_, {Value::Make(val * 2)}, results,
- out_trap);
- }
- results[0] = Value::Make(val);
- return Result::Ok;
- });
+ auto host_func =
+ HostFunc::New(store_, FuncType{{ValueType::I32}, {ValueType::I32}},
+ [&](Thread& thread, const Values& params, Values& results,
+ Trap::Ptr* out_trap) -> Result {
+ auto val = params[0].Get<u32>();
+ if (val < 10) {
+ return GetFuncExport(0)->Call(
+ store_, {Value::Make(val * 2)}, results, out_trap);
+ }
+ results[0] = Value::Make(val);
+ return Result::Ok;
+ });
Instantiate({host_func->self()});
@@ -328,7 +327,8 @@ TEST_F(InterpTest, HostFunc_PingPong) {
Values results;
Trap::Ptr trap;
- Result result = GetFuncExport(0)->Call(store_, {Value::Make(1)}, results, &trap);
+ Result result =
+ GetFuncExport(0)->Call(store_, {Value::Make(1)}, results, &trap);
ASSERT_EQ(Result::Ok, result);
EXPECT_EQ(1u, results.size());
@@ -368,7 +368,8 @@ TEST_F(InterpTest, HostFunc_PingPong_SameThread) {
Values results;
Trap::Ptr trap;
- Result result = GetFuncExport(0)->Call(*thread, {Value::Make(1)}, results, &trap);
+ Result result =
+ GetFuncExport(0)->Call(*thread, {Value::Make(1)}, results, &trap);
ASSERT_EQ(Result::Ok, result);
EXPECT_EQ(1u, results.size());
@@ -551,9 +552,7 @@ TEST_F(InterpTest, Rot13) {
class InterpGCTest : public InterpTest {
public:
- void SetUp() override {
- before_new = store_.object_count();
- }
+ void SetUp() override { before_new = store_.object_count(); }
void TearDown() override {
// Reset instance and module, in case they were allocated.
diff --git a/src/test-literal.cc b/src/test-literal.cc
index bce7a0b8..4a309d6e 100644
--- a/src/test-literal.cc
+++ b/src/test-literal.cc
@@ -87,8 +87,7 @@ void AssertInt64Equals(uint64_t expected,
AssertIntEquals(expected, s, ParseInt64, parse_type);
}
-void AssertUint128Equals(v128 expected,
- const char* s) {
+void AssertUint128Equals(v128 expected, const char* s) {
const char* const end = s + strlen(s);
v128 actual;
ASSERT_EQ(Result::Ok, ParseUint128(s, end, &actual)) << s;
@@ -474,138 +473,138 @@ TEST(ParseFloat, RoundingSpec) {
const char* input;
uint32_t output;
} kTests[] = {
- {"+0x1.00000100000000000p-50", 0x26800000},
- {"-0x1.00000100000000000p-50", 0xa6800000},
- {"+0x1.00000100000000001p-50", 0x26800001},
- {"-0x1.00000100000000001p-50", 0xa6800001},
- {"+0x1.000001fffffffffffp-50", 0x26800001},
- {"-0x1.000001fffffffffffp-50", 0xa6800001},
- {"+0x1.00000200000000000p-50", 0x26800001},
- {"-0x1.00000200000000000p-50", 0xa6800001},
- {"+0x1.00000200000000001p-50", 0x26800001},
- {"-0x1.00000200000000001p-50", 0xa6800001},
- {"+0x1.000002fffffffffffp-50", 0x26800001},
- {"-0x1.000002fffffffffffp-50", 0xa6800001},
- {"+0x1.00000300000000000p-50", 0x26800002},
- {"-0x1.00000300000000000p-50", 0xa6800002},
- {"+0x1.00000300000000001p-50", 0x26800002},
- {"-0x1.00000300000000001p-50", 0xa6800002},
- {"+0x1.000003fffffffffffp-50", 0x26800002},
- {"-0x1.000003fffffffffffp-50", 0xa6800002},
- {"+0x1.00000400000000000p-50", 0x26800002},
- {"-0x1.00000400000000000p-50", 0xa6800002},
- {"+0x1.00000400000000001p-50", 0x26800002},
- {"-0x1.00000400000000001p-50", 0xa6800002},
- {"+0x1.000004fffffffffffp-50", 0x26800002},
- {"-0x1.000004fffffffffffp-50", 0xa6800002},
- {"+0x1.00000500000000000p-50", 0x26800002},
- {"-0x1.00000500000000000p-50", 0xa6800002},
- {"+0x1.00000500000000001p-50", 0x26800003},
- {"-0x1.00000500000000001p-50", 0xa6800003},
- {"+0x4000.004000000p-64", 0x26800000},
- {"-0x4000.004000000p-64", 0xa6800000},
- {"+0x4000.004000001p-64", 0x26800001},
- {"-0x4000.004000001p-64", 0xa6800001},
- {"+0x4000.007ffffffp-64", 0x26800001},
- {"-0x4000.007ffffffp-64", 0xa6800001},
- {"+0x4000.008000000p-64", 0x26800001},
- {"-0x4000.008000000p-64", 0xa6800001},
- {"+0x4000.008000001p-64", 0x26800001},
- {"-0x4000.008000001p-64", 0xa6800001},
- {"+0x4000.00bffffffp-64", 0x26800001},
- {"-0x4000.00bffffffp-64", 0xa6800001},
- {"+0x4000.00c000000p-64", 0x26800002},
- {"-0x4000.00c000000p-64", 0xa6800002},
- {"+0x4000.00c000001p-64", 0x26800002},
- {"-0x4000.00c000001p-64", 0xa6800002},
- {"+0x4000.00fffffffp-64", 0x26800002},
- {"-0x4000.00fffffffp-64", 0xa6800002},
- {"+0x4000.010000001p-64", 0x26800002},
- {"-0x4000.010000001p-64", 0xa6800002},
- {"+0x4000.013ffffffp-64", 0x26800002},
- {"-0x4000.013ffffffp-64", 0xa6800002},
- {"+0x4000.014000001p-64", 0x26800003},
- {"-0x4000.014000001p-64", 0xa6800003},
- {"+0x1.00000100000000000p+50", 0x58800000},
- {"-0x1.00000100000000000p+50", 0xd8800000},
- {"+0x1.00000100000000001p+50", 0x58800001},
- {"-0x1.00000100000000001p+50", 0xd8800001},
- {"+0x1.000001fffffffffffp+50", 0x58800001},
- {"-0x1.000001fffffffffffp+50", 0xd8800001},
- {"+0x1.00000200000000000p+50", 0x58800001},
- {"-0x1.00000200000000000p+50", 0xd8800001},
- {"+0x1.00000200000000001p+50", 0x58800001},
- {"-0x1.00000200000000001p+50", 0xd8800001},
- {"+0x1.000002fffffffffffp+50", 0x58800001},
- {"-0x1.000002fffffffffffp+50", 0xd8800001},
- {"+0x1.00000300000000000p+50", 0x58800002},
- {"-0x1.00000300000000000p+50", 0xd8800002},
- {"+0x1.00000300000000001p+50", 0x58800002},
- {"-0x1.00000300000000001p+50", 0xd8800002},
- {"+0x1.000003fffffffffffp+50", 0x58800002},
- {"-0x1.000003fffffffffffp+50", 0xd8800002},
- {"+0x1.00000400000000000p+50", 0x58800002},
- {"-0x1.00000400000000000p+50", 0xd8800002},
- {"+0x1.00000400000000001p+50", 0x58800002},
- {"-0x1.00000400000000001p+50", 0xd8800002},
- {"+0x1.000004fffffffffffp+50", 0x58800002},
- {"-0x1.000004fffffffffffp+50", 0xd8800002},
- {"+0x1.00000500000000000p+50", 0x58800002},
- {"-0x1.00000500000000000p+50", 0xd8800002},
- {"+0x1.00000500000000001p+50", 0x58800003},
- {"-0x1.00000500000000001p+50", 0xd8800003},
- {"+0x4000004000000", 0x58800000},
- {"-0x4000004000000", 0xd8800000},
- {"+0x4000004000001", 0x58800001},
- {"-0x4000004000001", 0xd8800001},
- {"+0x4000007ffffff", 0x58800001},
- {"-0x4000007ffffff", 0xd8800001},
- {"+0x4000008000000", 0x58800001},
- {"-0x4000008000000", 0xd8800001},
- {"+0x4000008000001", 0x58800001},
- {"-0x4000008000001", 0xd8800001},
- {"+0x400000bffffff", 0x58800001},
- {"-0x400000bffffff", 0xd8800001},
- {"+0x400000c000000", 0x58800002},
- {"-0x400000c000000", 0xd8800002},
- {"+0x0.00000100000000000p-126", 0x0},
- {"-0x0.00000100000000000p-126", 0x80000000},
- {"+0x0.00000100000000001p-126", 0x1},
- {"-0x0.00000100000000001p-126", 0x80000001},
- {"+0x0.00000101000000000p-126", 0x1},
- {"+0x0.000001fffffffffffp-126", 0x1},
- {"-0x0.000001fffffffffffp-126", 0x80000001},
- {"+0x0.00000200000000000p-126", 0x1},
- {"-0x0.00000200000000000p-126", 0x80000001},
- {"+0x0.00000200000000001p-126", 0x1},
- {"-0x0.00000200000000001p-126", 0x80000001},
- {"+0x0.000002fffffffffffp-126", 0x1},
- {"-0x0.000002fffffffffffp-126", 0x80000001},
- {"+0x0.00000300000000000p-126", 0x2},
- {"-0x0.00000300000000000p-126", 0x80000002},
- {"+0x0.00000300000000001p-126", 0x2},
- {"-0x0.00000300000000001p-126", 0x80000002},
- {"+0x0.000003fffffffffffp-126", 0x2},
- {"-0x0.000003fffffffffffp-126", 0x80000002},
- {"+0x0.00000400000000000p-126", 0x2},
- {"-0x0.00000400000000000p-126", 0x80000002},
- {"+0x0.00000400000000001p-126", 0x2},
- {"-0x0.00000400000000001p-126", 0x80000002},
- {"+0x0.000004fffffffffffp-126", 0x2},
- {"-0x0.000004fffffffffffp-126", 0x80000002},
- {"+0x0.00000500000000000p-126", 0x2},
- {"-0x0.00000500000000000p-126", 0x80000002},
- {"+0x0.00000500000000001p-126", 0x3},
- {"-0x0.00000500000000001p-126", 0x80000003},
- {"+0x1.fffffe8p127", 0x7f7fffff},
- {"-0x1.fffffe8p127", 0xff7fffff},
- {"+0x1.fffffefffffff8p127", 0x7f7fffff},
- {"-0x1.fffffefffffff8p127", 0xff7fffff},
- {"+0x1.fffffefffffffffffp127", 0x7f7fffff},
- {"-0x1.fffffefffffffffffp127", 0xff7fffff},
+ {"+0x1.00000100000000000p-50", 0x26800000},
+ {"-0x1.00000100000000000p-50", 0xa6800000},
+ {"+0x1.00000100000000001p-50", 0x26800001},
+ {"-0x1.00000100000000001p-50", 0xa6800001},
+ {"+0x1.000001fffffffffffp-50", 0x26800001},
+ {"-0x1.000001fffffffffffp-50", 0xa6800001},
+ {"+0x1.00000200000000000p-50", 0x26800001},
+ {"-0x1.00000200000000000p-50", 0xa6800001},
+ {"+0x1.00000200000000001p-50", 0x26800001},
+ {"-0x1.00000200000000001p-50", 0xa6800001},
+ {"+0x1.000002fffffffffffp-50", 0x26800001},
+ {"-0x1.000002fffffffffffp-50", 0xa6800001},
+ {"+0x1.00000300000000000p-50", 0x26800002},
+ {"-0x1.00000300000000000p-50", 0xa6800002},
+ {"+0x1.00000300000000001p-50", 0x26800002},
+ {"-0x1.00000300000000001p-50", 0xa6800002},
+ {"+0x1.000003fffffffffffp-50", 0x26800002},
+ {"-0x1.000003fffffffffffp-50", 0xa6800002},
+ {"+0x1.00000400000000000p-50", 0x26800002},
+ {"-0x1.00000400000000000p-50", 0xa6800002},
+ {"+0x1.00000400000000001p-50", 0x26800002},
+ {"-0x1.00000400000000001p-50", 0xa6800002},
+ {"+0x1.000004fffffffffffp-50", 0x26800002},
+ {"-0x1.000004fffffffffffp-50", 0xa6800002},
+ {"+0x1.00000500000000000p-50", 0x26800002},
+ {"-0x1.00000500000000000p-50", 0xa6800002},
+ {"+0x1.00000500000000001p-50", 0x26800003},
+ {"-0x1.00000500000000001p-50", 0xa6800003},
+ {"+0x4000.004000000p-64", 0x26800000},
+ {"-0x4000.004000000p-64", 0xa6800000},
+ {"+0x4000.004000001p-64", 0x26800001},
+ {"-0x4000.004000001p-64", 0xa6800001},
+ {"+0x4000.007ffffffp-64", 0x26800001},
+ {"-0x4000.007ffffffp-64", 0xa6800001},
+ {"+0x4000.008000000p-64", 0x26800001},
+ {"-0x4000.008000000p-64", 0xa6800001},
+ {"+0x4000.008000001p-64", 0x26800001},
+ {"-0x4000.008000001p-64", 0xa6800001},
+ {"+0x4000.00bffffffp-64", 0x26800001},
+ {"-0x4000.00bffffffp-64", 0xa6800001},
+ {"+0x4000.00c000000p-64", 0x26800002},
+ {"-0x4000.00c000000p-64", 0xa6800002},
+ {"+0x4000.00c000001p-64", 0x26800002},
+ {"-0x4000.00c000001p-64", 0xa6800002},
+ {"+0x4000.00fffffffp-64", 0x26800002},
+ {"-0x4000.00fffffffp-64", 0xa6800002},
+ {"+0x4000.010000001p-64", 0x26800002},
+ {"-0x4000.010000001p-64", 0xa6800002},
+ {"+0x4000.013ffffffp-64", 0x26800002},
+ {"-0x4000.013ffffffp-64", 0xa6800002},
+ {"+0x4000.014000001p-64", 0x26800003},
+ {"-0x4000.014000001p-64", 0xa6800003},
+ {"+0x1.00000100000000000p+50", 0x58800000},
+ {"-0x1.00000100000000000p+50", 0xd8800000},
+ {"+0x1.00000100000000001p+50", 0x58800001},
+ {"-0x1.00000100000000001p+50", 0xd8800001},
+ {"+0x1.000001fffffffffffp+50", 0x58800001},
+ {"-0x1.000001fffffffffffp+50", 0xd8800001},
+ {"+0x1.00000200000000000p+50", 0x58800001},
+ {"-0x1.00000200000000000p+50", 0xd8800001},
+ {"+0x1.00000200000000001p+50", 0x58800001},
+ {"-0x1.00000200000000001p+50", 0xd8800001},
+ {"+0x1.000002fffffffffffp+50", 0x58800001},
+ {"-0x1.000002fffffffffffp+50", 0xd8800001},
+ {"+0x1.00000300000000000p+50", 0x58800002},
+ {"-0x1.00000300000000000p+50", 0xd8800002},
+ {"+0x1.00000300000000001p+50", 0x58800002},
+ {"-0x1.00000300000000001p+50", 0xd8800002},
+ {"+0x1.000003fffffffffffp+50", 0x58800002},
+ {"-0x1.000003fffffffffffp+50", 0xd8800002},
+ {"+0x1.00000400000000000p+50", 0x58800002},
+ {"-0x1.00000400000000000p+50", 0xd8800002},
+ {"+0x1.00000400000000001p+50", 0x58800002},
+ {"-0x1.00000400000000001p+50", 0xd8800002},
+ {"+0x1.000004fffffffffffp+50", 0x58800002},
+ {"-0x1.000004fffffffffffp+50", 0xd8800002},
+ {"+0x1.00000500000000000p+50", 0x58800002},
+ {"-0x1.00000500000000000p+50", 0xd8800002},
+ {"+0x1.00000500000000001p+50", 0x58800003},
+ {"-0x1.00000500000000001p+50", 0xd8800003},
+ {"+0x4000004000000", 0x58800000},
+ {"-0x4000004000000", 0xd8800000},
+ {"+0x4000004000001", 0x58800001},
+ {"-0x4000004000001", 0xd8800001},
+ {"+0x4000007ffffff", 0x58800001},
+ {"-0x4000007ffffff", 0xd8800001},
+ {"+0x4000008000000", 0x58800001},
+ {"-0x4000008000000", 0xd8800001},
+ {"+0x4000008000001", 0x58800001},
+ {"-0x4000008000001", 0xd8800001},
+ {"+0x400000bffffff", 0x58800001},
+ {"-0x400000bffffff", 0xd8800001},
+ {"+0x400000c000000", 0x58800002},
+ {"-0x400000c000000", 0xd8800002},
+ {"+0x0.00000100000000000p-126", 0x0},
+ {"-0x0.00000100000000000p-126", 0x80000000},
+ {"+0x0.00000100000000001p-126", 0x1},
+ {"-0x0.00000100000000001p-126", 0x80000001},
+ {"+0x0.00000101000000000p-126", 0x1},
+ {"+0x0.000001fffffffffffp-126", 0x1},
+ {"-0x0.000001fffffffffffp-126", 0x80000001},
+ {"+0x0.00000200000000000p-126", 0x1},
+ {"-0x0.00000200000000000p-126", 0x80000001},
+ {"+0x0.00000200000000001p-126", 0x1},
+ {"-0x0.00000200000000001p-126", 0x80000001},
+ {"+0x0.000002fffffffffffp-126", 0x1},
+ {"-0x0.000002fffffffffffp-126", 0x80000001},
+ {"+0x0.00000300000000000p-126", 0x2},
+ {"-0x0.00000300000000000p-126", 0x80000002},
+ {"+0x0.00000300000000001p-126", 0x2},
+ {"-0x0.00000300000000001p-126", 0x80000002},
+ {"+0x0.000003fffffffffffp-126", 0x2},
+ {"-0x0.000003fffffffffffp-126", 0x80000002},
+ {"+0x0.00000400000000000p-126", 0x2},
+ {"-0x0.00000400000000000p-126", 0x80000002},
+ {"+0x0.00000400000000001p-126", 0x2},
+ {"-0x0.00000400000000001p-126", 0x80000002},
+ {"+0x0.000004fffffffffffp-126", 0x2},
+ {"-0x0.000004fffffffffffp-126", 0x80000002},
+ {"+0x0.00000500000000000p-126", 0x2},
+ {"-0x0.00000500000000000p-126", 0x80000002},
+ {"+0x0.00000500000000001p-126", 0x3},
+ {"-0x0.00000500000000001p-126", 0x80000003},
+ {"+0x1.fffffe8p127", 0x7f7fffff},
+ {"-0x1.fffffe8p127", 0xff7fffff},
+ {"+0x1.fffffefffffff8p127", 0x7f7fffff},
+ {"-0x1.fffffefffffff8p127", 0xff7fffff},
+ {"+0x1.fffffefffffffffffp127", 0x7f7fffff},
+ {"-0x1.fffffefffffffffffp127", 0xff7fffff},
};
- for (auto test: kTests) {
+ for (auto test : kTests) {
AssertHexFloatEquals(test.output, test.input);
}
}
@@ -651,149 +650,149 @@ TEST(ParseDouble, RoundingSpec) {
const char* input;
uint64_t output;
} kTests[] = {
- {"+0x1.000000000000080000000000p-600", 1905022642377719808ull},
- {"-0x1.000000000000080000000000p-600", 11128394679232495616ull},
- {"+0x1.000000000000080000000001p-600", 1905022642377719809ull},
- {"-0x1.000000000000080000000001p-600", 11128394679232495617ull},
- {"+0x1.0000000000000fffffffffffp-600", 1905022642377719809ull},
- {"-0x1.0000000000000fffffffffffp-600", 11128394679232495617ull},
- {"+0x1.000000000000100000000000p-600", 1905022642377719809ull},
- {"-0x1.000000000000100000000000p-600", 11128394679232495617ull},
- {"+0x1.000000000000100000000001p-600", 1905022642377719809ull},
- {"-0x1.000000000000100000000001p-600", 11128394679232495617ull},
- {"+0x1.00000000000017ffffffffffp-600", 1905022642377719809ull},
- {"-0x1.00000000000017ffffffffffp-600", 11128394679232495617ull},
- {"+0x1.000000000000180000000000p-600", 1905022642377719810ull},
- {"-0x1.000000000000180000000000p-600", 11128394679232495618ull},
- {"+0x1.000000000000180000000001p-600", 1905022642377719810ull},
- {"-0x1.000000000000180000000001p-600", 11128394679232495618ull},
- {"+0x1.0000000000001fffffffffffp-600", 1905022642377719810ull},
- {"-0x1.0000000000001fffffffffffp-600", 11128394679232495618ull},
- {"+0x1.000000000000200000000000p-600", 1905022642377719810ull},
- {"-0x1.000000000000200000000000p-600", 11128394679232495618ull},
- {"+0x1.000000000000200000000001p-600", 1905022642377719810ull},
- {"-0x1.000000000000200000000001p-600", 11128394679232495618ull},
- {"+0x1.00000000000027ffffffffffp-600", 1905022642377719810ull},
- {"-0x1.00000000000027ffffffffffp-600", 11128394679232495618ull},
- {"+0x1.000000000000280000000001p-600", 1905022642377719811ull},
- {"-0x1.000000000000280000000001p-600", 11128394679232495619ull},
- {"+0x8000000.000000400000000000p-627", 1905022642377719808ull},
- {"-0x8000000.000000400000000000p-627", 11128394679232495616ull},
- {"+0x8000000.000000400000000001p-627", 1905022642377719809ull},
- {"-0x8000000.000000400000000001p-627", 11128394679232495617ull},
- {"+0x8000000.0000007fffffffffffp-627", 1905022642377719809ull},
- {"-0x8000000.0000007fffffffffffp-627", 11128394679232495617ull},
- {"+0x8000000.000000800000000000p-627", 1905022642377719809ull},
- {"-0x8000000.000000800000000000p-627", 11128394679232495617ull},
- {"+0x8000000.000000800000000001p-627", 1905022642377719809ull},
- {"-0x8000000.000000800000000001p-627", 11128394679232495617ull},
- {"+0x8000000.000000bfffffffffffp-627", 1905022642377719809ull},
- {"-0x8000000.000000bfffffffffffp-627", 11128394679232495617ull},
- {"+0x8000000.000000c00000000000p-627", 1905022642377719810ull},
- {"-0x8000000.000000c00000000000p-627", 11128394679232495618ull},
- {"+0x8000000.000000c00000000001p-627", 1905022642377719810ull},
- {"-0x8000000.000000c00000000001p-627", 11128394679232495618ull},
- {"+0x8000000.000000ffffffffffffp-627", 1905022642377719810ull},
- {"-0x8000000.000000ffffffffffffp-627", 11128394679232495618ull},
- {"+0x8000000.000001000000000000p-627", 1905022642377719810ull},
- {"-0x8000000.000001000000000000p-627", 11128394679232495618ull},
- {"+0x8000000.000001000000000001p-627", 1905022642377719810ull},
- {"-0x8000000.000001000000000001p-627", 11128394679232495618ull},
- {"+0x8000000.0000013fffffffffffp-627", 1905022642377719810ull},
- {"-0x8000000.0000013fffffffffffp-627", 11128394679232495618ull},
- {"+0x8000000.000001400000000001p-627", 1905022642377719811ull},
- {"-0x8000000.000001400000000001p-627", 11128394679232495619ull},
- {"+0x1.000000000000080000000000p+600", 7309342195222315008ull},
- {"-0x1.000000000000080000000000p+600", 16532714232077090816ull},
- {"+0x1.000000000000080000000001p+600", 7309342195222315009ull},
- {"-0x1.000000000000080000000001p+600", 16532714232077090817ull},
- {"+0x1.0000000000000fffffffffffp+600", 7309342195222315009ull},
- {"-0x1.0000000000000fffffffffffp+600", 16532714232077090817ull},
- {"+0x1.000000000000100000000000p+600", 7309342195222315009ull},
- {"-0x1.000000000000100000000000p+600", 16532714232077090817ull},
- {"+0x1.000000000000100000000001p+600", 7309342195222315009ull},
- {"-0x1.000000000000100000000001p+600", 16532714232077090817ull},
- {"+0x1.00000000000017ffffffffffp+600", 7309342195222315009ull},
- {"-0x1.00000000000017ffffffffffp+600", 16532714232077090817ull},
- {"+0x1.000000000000180000000000p+600", 7309342195222315010ull},
- {"-0x1.000000000000180000000000p+600", 16532714232077090818ull},
- {"+0x1.000000000000180000000001p+600", 7309342195222315010ull},
- {"-0x1.000000000000180000000001p+600", 16532714232077090818ull},
- {"+0x1.0000000000001fffffffffffp+600", 7309342195222315010ull},
- {"-0x1.0000000000001fffffffffffp+600", 16532714232077090818ull},
- {"+0x1.000000000000200000000000p+600", 7309342195222315010ull},
- {"-0x1.000000000000200000000000p+600", 16532714232077090818ull},
- {"+0x1.000000000000200000000001p+600", 7309342195222315010ull},
- {"-0x1.000000000000200000000001p+600", 16532714232077090818ull},
- {"+0x1.00000000000027ffffffffffp+600", 7309342195222315010ull},
- {"-0x1.00000000000027ffffffffffp+600", 16532714232077090818ull},
- {"+0x1.000000000000280000000000p+600", 7309342195222315010ull},
- {"-0x1.000000000000280000000000p+600", 16532714232077090818ull},
- {"+0x1.000000000000280000000001p+600", 7309342195222315011ull},
- {"-0x1.000000000000280000000001p+600", 16532714232077090819ull},
- {"+0x2000000000000100000000000", 5044031582654955520ull},
- {"-0x2000000000000100000000000", 14267403619509731328ull},
- {"+0x2000000000000100000000001", 5044031582654955521ull},
- {"-0x2000000000000100000000001", 14267403619509731329ull},
- {"+0x20000000000001fffffffffff", 5044031582654955521ull},
- {"-0x20000000000001fffffffffff", 14267403619509731329ull},
- {"+0x2000000000000200000000000", 5044031582654955521ull},
- {"-0x2000000000000200000000000", 14267403619509731329ull},
- {"+0x2000000000000200000000001", 5044031582654955521ull},
- {"-0x2000000000000200000000001", 14267403619509731329ull},
- {"+0x20000000000002fffffffffff", 5044031582654955521ull},
- {"-0x20000000000002fffffffffff", 14267403619509731329ull},
- {"+0x2000000000000300000000000", 5044031582654955522ull},
- {"-0x2000000000000300000000000", 14267403619509731330ull},
- {"+0x2000000000000300000000001", 5044031582654955522ull},
- {"-0x2000000000000300000000001", 14267403619509731330ull},
- {"+0x20000000000003fffffffffff", 5044031582654955522ull},
- {"-0x20000000000003fffffffffff", 14267403619509731330ull},
- {"+0x2000000000000400000000000", 5044031582654955522ull},
- {"-0x2000000000000400000000000", 14267403619509731330ull},
- {"+0x2000000000000400000000001", 5044031582654955522ull},
- {"-0x2000000000000400000000001", 14267403619509731330ull},
- {"+0x20000000000004fffffffffff", 5044031582654955522ull},
- {"-0x20000000000004fffffffffff", 14267403619509731330ull},
- {"+0x2000000000000500000000000", 5044031582654955522ull},
- {"-0x2000000000000500000000000", 14267403619509731330ull},
- {"+0x2000000000000500000000001", 5044031582654955523ull},
- {"-0x2000000000000500000000001", 14267403619509731331ull},
- {"+0x0.000000000000080000000000p-1022", 0ull},
- {"-0x0.000000000000080000000000p-1022", 9223372036854775808ull},
- {"+0x0.000000000000080000000001p-1022", 1ull},
- {"-0x0.000000000000080000000001p-1022", 9223372036854775809ull},
- {"+0x0.0000000000000fffffffffffp-1022", 1ull},
- {"-0x0.0000000000000fffffffffffp-1022", 9223372036854775809ull},
- {"+0x0.000000000000100000000000p-1022", 1ull},
- {"-0x0.000000000000100000000000p-1022", 9223372036854775809ull},
- {"+0x0.000000000000100000000001p-1022", 1ull},
- {"-0x0.000000000000100000000001p-1022", 9223372036854775809ull},
- {"+0x0.00000000000017ffffffffffp-1022", 1ull},
- {"-0x0.00000000000017ffffffffffp-1022", 9223372036854775809ull},
- {"+0x0.000000000000180000000000p-1022", 2ull},
- {"-0x0.000000000000180000000000p-1022", 9223372036854775810ull},
- {"+0x0.000000000000180000000001p-1022", 2ull},
- {"-0x0.000000000000180000000001p-1022", 9223372036854775810ull},
- {"+0x0.0000000000001fffffffffffp-1022", 2ull},
- {"-0x0.0000000000001fffffffffffp-1022", 9223372036854775810ull},
- {"+0x0.000000000000200000000000p-1022", 2ull},
- {"-0x0.000000000000200000000000p-1022", 9223372036854775810ull},
- {"+0x0.000000000000200000000001p-1022", 2ull},
- {"-0x0.000000000000200000000001p-1022", 9223372036854775810ull},
- {"+0x0.00000000000027ffffffffffp-1022", 2ull},
- {"-0x0.00000000000027ffffffffffp-1022", 9223372036854775810ull},
- {"+0x0.000000000000280000000000p-1022", 2ull},
- {"-0x0.000000000000280000000000p-1022", 9223372036854775810ull},
- {"+0x1.000000000000280000000001p-1022", 4503599627370499ull},
- {"-0x1.000000000000280000000001p-1022", 9227875636482146307ull},
- {"+0x1.fffffffffffff4p1023", 9218868437227405311ull},
- {"-0x1.fffffffffffff4p1023", 18442240474082181119ull},
- {"+0x1.fffffffffffff7ffffffp1023", 9218868437227405311ull},
- {"-0x1.fffffffffffff7ffffffp1023", 18442240474082181119ull},
+ {"+0x1.000000000000080000000000p-600", 1905022642377719808ull},
+ {"-0x1.000000000000080000000000p-600", 11128394679232495616ull},
+ {"+0x1.000000000000080000000001p-600", 1905022642377719809ull},
+ {"-0x1.000000000000080000000001p-600", 11128394679232495617ull},
+ {"+0x1.0000000000000fffffffffffp-600", 1905022642377719809ull},
+ {"-0x1.0000000000000fffffffffffp-600", 11128394679232495617ull},
+ {"+0x1.000000000000100000000000p-600", 1905022642377719809ull},
+ {"-0x1.000000000000100000000000p-600", 11128394679232495617ull},
+ {"+0x1.000000000000100000000001p-600", 1905022642377719809ull},
+ {"-0x1.000000000000100000000001p-600", 11128394679232495617ull},
+ {"+0x1.00000000000017ffffffffffp-600", 1905022642377719809ull},
+ {"-0x1.00000000000017ffffffffffp-600", 11128394679232495617ull},
+ {"+0x1.000000000000180000000000p-600", 1905022642377719810ull},
+ {"-0x1.000000000000180000000000p-600", 11128394679232495618ull},
+ {"+0x1.000000000000180000000001p-600", 1905022642377719810ull},
+ {"-0x1.000000000000180000000001p-600", 11128394679232495618ull},
+ {"+0x1.0000000000001fffffffffffp-600", 1905022642377719810ull},
+ {"-0x1.0000000000001fffffffffffp-600", 11128394679232495618ull},
+ {"+0x1.000000000000200000000000p-600", 1905022642377719810ull},
+ {"-0x1.000000000000200000000000p-600", 11128394679232495618ull},
+ {"+0x1.000000000000200000000001p-600", 1905022642377719810ull},
+ {"-0x1.000000000000200000000001p-600", 11128394679232495618ull},
+ {"+0x1.00000000000027ffffffffffp-600", 1905022642377719810ull},
+ {"-0x1.00000000000027ffffffffffp-600", 11128394679232495618ull},
+ {"+0x1.000000000000280000000001p-600", 1905022642377719811ull},
+ {"-0x1.000000000000280000000001p-600", 11128394679232495619ull},
+ {"+0x8000000.000000400000000000p-627", 1905022642377719808ull},
+ {"-0x8000000.000000400000000000p-627", 11128394679232495616ull},
+ {"+0x8000000.000000400000000001p-627", 1905022642377719809ull},
+ {"-0x8000000.000000400000000001p-627", 11128394679232495617ull},
+ {"+0x8000000.0000007fffffffffffp-627", 1905022642377719809ull},
+ {"-0x8000000.0000007fffffffffffp-627", 11128394679232495617ull},
+ {"+0x8000000.000000800000000000p-627", 1905022642377719809ull},
+ {"-0x8000000.000000800000000000p-627", 11128394679232495617ull},
+ {"+0x8000000.000000800000000001p-627", 1905022642377719809ull},
+ {"-0x8000000.000000800000000001p-627", 11128394679232495617ull},
+ {"+0x8000000.000000bfffffffffffp-627", 1905022642377719809ull},
+ {"-0x8000000.000000bfffffffffffp-627", 11128394679232495617ull},
+ {"+0x8000000.000000c00000000000p-627", 1905022642377719810ull},
+ {"-0x8000000.000000c00000000000p-627", 11128394679232495618ull},
+ {"+0x8000000.000000c00000000001p-627", 1905022642377719810ull},
+ {"-0x8000000.000000c00000000001p-627", 11128394679232495618ull},
+ {"+0x8000000.000000ffffffffffffp-627", 1905022642377719810ull},
+ {"-0x8000000.000000ffffffffffffp-627", 11128394679232495618ull},
+ {"+0x8000000.000001000000000000p-627", 1905022642377719810ull},
+ {"-0x8000000.000001000000000000p-627", 11128394679232495618ull},
+ {"+0x8000000.000001000000000001p-627", 1905022642377719810ull},
+ {"-0x8000000.000001000000000001p-627", 11128394679232495618ull},
+ {"+0x8000000.0000013fffffffffffp-627", 1905022642377719810ull},
+ {"-0x8000000.0000013fffffffffffp-627", 11128394679232495618ull},
+ {"+0x8000000.000001400000000001p-627", 1905022642377719811ull},
+ {"-0x8000000.000001400000000001p-627", 11128394679232495619ull},
+ {"+0x1.000000000000080000000000p+600", 7309342195222315008ull},
+ {"-0x1.000000000000080000000000p+600", 16532714232077090816ull},
+ {"+0x1.000000000000080000000001p+600", 7309342195222315009ull},
+ {"-0x1.000000000000080000000001p+600", 16532714232077090817ull},
+ {"+0x1.0000000000000fffffffffffp+600", 7309342195222315009ull},
+ {"-0x1.0000000000000fffffffffffp+600", 16532714232077090817ull},
+ {"+0x1.000000000000100000000000p+600", 7309342195222315009ull},
+ {"-0x1.000000000000100000000000p+600", 16532714232077090817ull},
+ {"+0x1.000000000000100000000001p+600", 7309342195222315009ull},
+ {"-0x1.000000000000100000000001p+600", 16532714232077090817ull},
+ {"+0x1.00000000000017ffffffffffp+600", 7309342195222315009ull},
+ {"-0x1.00000000000017ffffffffffp+600", 16532714232077090817ull},
+ {"+0x1.000000000000180000000000p+600", 7309342195222315010ull},
+ {"-0x1.000000000000180000000000p+600", 16532714232077090818ull},
+ {"+0x1.000000000000180000000001p+600", 7309342195222315010ull},
+ {"-0x1.000000000000180000000001p+600", 16532714232077090818ull},
+ {"+0x1.0000000000001fffffffffffp+600", 7309342195222315010ull},
+ {"-0x1.0000000000001fffffffffffp+600", 16532714232077090818ull},
+ {"+0x1.000000000000200000000000p+600", 7309342195222315010ull},
+ {"-0x1.000000000000200000000000p+600", 16532714232077090818ull},
+ {"+0x1.000000000000200000000001p+600", 7309342195222315010ull},
+ {"-0x1.000000000000200000000001p+600", 16532714232077090818ull},
+ {"+0x1.00000000000027ffffffffffp+600", 7309342195222315010ull},
+ {"-0x1.00000000000027ffffffffffp+600", 16532714232077090818ull},
+ {"+0x1.000000000000280000000000p+600", 7309342195222315010ull},
+ {"-0x1.000000000000280000000000p+600", 16532714232077090818ull},
+ {"+0x1.000000000000280000000001p+600", 7309342195222315011ull},
+ {"-0x1.000000000000280000000001p+600", 16532714232077090819ull},
+ {"+0x2000000000000100000000000", 5044031582654955520ull},
+ {"-0x2000000000000100000000000", 14267403619509731328ull},
+ {"+0x2000000000000100000000001", 5044031582654955521ull},
+ {"-0x2000000000000100000000001", 14267403619509731329ull},
+ {"+0x20000000000001fffffffffff", 5044031582654955521ull},
+ {"-0x20000000000001fffffffffff", 14267403619509731329ull},
+ {"+0x2000000000000200000000000", 5044031582654955521ull},
+ {"-0x2000000000000200000000000", 14267403619509731329ull},
+ {"+0x2000000000000200000000001", 5044031582654955521ull},
+ {"-0x2000000000000200000000001", 14267403619509731329ull},
+ {"+0x20000000000002fffffffffff", 5044031582654955521ull},
+ {"-0x20000000000002fffffffffff", 14267403619509731329ull},
+ {"+0x2000000000000300000000000", 5044031582654955522ull},
+ {"-0x2000000000000300000000000", 14267403619509731330ull},
+ {"+0x2000000000000300000000001", 5044031582654955522ull},
+ {"-0x2000000000000300000000001", 14267403619509731330ull},
+ {"+0x20000000000003fffffffffff", 5044031582654955522ull},
+ {"-0x20000000000003fffffffffff", 14267403619509731330ull},
+ {"+0x2000000000000400000000000", 5044031582654955522ull},
+ {"-0x2000000000000400000000000", 14267403619509731330ull},
+ {"+0x2000000000000400000000001", 5044031582654955522ull},
+ {"-0x2000000000000400000000001", 14267403619509731330ull},
+ {"+0x20000000000004fffffffffff", 5044031582654955522ull},
+ {"-0x20000000000004fffffffffff", 14267403619509731330ull},
+ {"+0x2000000000000500000000000", 5044031582654955522ull},
+ {"-0x2000000000000500000000000", 14267403619509731330ull},
+ {"+0x2000000000000500000000001", 5044031582654955523ull},
+ {"-0x2000000000000500000000001", 14267403619509731331ull},
+ {"+0x0.000000000000080000000000p-1022", 0ull},
+ {"-0x0.000000000000080000000000p-1022", 9223372036854775808ull},
+ {"+0x0.000000000000080000000001p-1022", 1ull},
+ {"-0x0.000000000000080000000001p-1022", 9223372036854775809ull},
+ {"+0x0.0000000000000fffffffffffp-1022", 1ull},
+ {"-0x0.0000000000000fffffffffffp-1022", 9223372036854775809ull},
+ {"+0x0.000000000000100000000000p-1022", 1ull},
+ {"-0x0.000000000000100000000000p-1022", 9223372036854775809ull},
+ {"+0x0.000000000000100000000001p-1022", 1ull},
+ {"-0x0.000000000000100000000001p-1022", 9223372036854775809ull},
+ {"+0x0.00000000000017ffffffffffp-1022", 1ull},
+ {"-0x0.00000000000017ffffffffffp-1022", 9223372036854775809ull},
+ {"+0x0.000000000000180000000000p-1022", 2ull},
+ {"-0x0.000000000000180000000000p-1022", 9223372036854775810ull},
+ {"+0x0.000000000000180000000001p-1022", 2ull},
+ {"-0x0.000000000000180000000001p-1022", 9223372036854775810ull},
+ {"+0x0.0000000000001fffffffffffp-1022", 2ull},
+ {"-0x0.0000000000001fffffffffffp-1022", 9223372036854775810ull},
+ {"+0x0.000000000000200000000000p-1022", 2ull},
+ {"-0x0.000000000000200000000000p-1022", 9223372036854775810ull},
+ {"+0x0.000000000000200000000001p-1022", 2ull},
+ {"-0x0.000000000000200000000001p-1022", 9223372036854775810ull},
+ {"+0x0.00000000000027ffffffffffp-1022", 2ull},
+ {"-0x0.00000000000027ffffffffffp-1022", 9223372036854775810ull},
+ {"+0x0.000000000000280000000000p-1022", 2ull},
+ {"-0x0.000000000000280000000000p-1022", 9223372036854775810ull},
+ {"+0x1.000000000000280000000001p-1022", 4503599627370499ull},
+ {"-0x1.000000000000280000000001p-1022", 9227875636482146307ull},
+ {"+0x1.fffffffffffff4p1023", 9218868437227405311ull},
+ {"-0x1.fffffffffffff4p1023", 18442240474082181119ull},
+ {"+0x1.fffffffffffff7ffffffp1023", 9218868437227405311ull},
+ {"-0x1.fffffffffffff7ffffffp1023", 18442240474082181119ull},
};
- for (auto test: kTests) {
+ for (auto test : kTests) {
AssertHexDoubleEquals(test.output, test.input);
}
}
diff --git a/src/test-option-parser.cc b/src/test-option-parser.cc
index 9295c581..6d6c4db5 100644
--- a/src/test-option-parser.cc
+++ b/src/test-option-parser.cc
@@ -119,7 +119,6 @@ TEST(OptionParser, FlagCombinedAfterShortParam) {
EXPECT_EQ(error, "prog: unexpected argument 'stuff'" ERROR_ENDING);
}
-
TEST(OptionParser, OneArgument) {
std::string argument;
OptionParser parser("prog", "desc");
diff --git a/src/tools/spectest-interp.cc b/src/tools/spectest-interp.cc
index e1bec2f6..bf428424 100644
--- a/src/tools/spectest-interp.cc
+++ b/src/tools/spectest-interp.cc
@@ -164,7 +164,7 @@ class RegisterCommand : public CommandMixin<CommandType::Register> {
struct ExpectedValue {
TypedValue value;
- Type lane_type; // Only valid if value.type == Type::V128.
+ Type lane_type; // Only valid if value.type == Type::V128.
// Up to 4 NaN values used, depending on |value.type| and |lane_type|:
// | type | lane_type | valid |
// | f32 | | nan[0] |
@@ -898,7 +898,8 @@ wabt::Result JSONParser::ParseExpectedValues(
return wabt::Result::Ok;
}
-wabt::Result JSONParser::ParseConstVector(ValueTypes* out_types, Values* out_values) {
+wabt::Result JSONParser::ParseConstVector(ValueTypes* out_types,
+ Values* out_values) {
out_values->clear();
EXPECT("[");
bool first = true;
@@ -1205,16 +1206,16 @@ class CommandRunner {
wabt::Result ReadInvalidTextModule(string_view module_filename,
const std::string& header);
wabt::Result ReadInvalidModule(int line_number,
- string_view module_filename,
- ModuleType module_type,
- const char* desc);
+ string_view module_filename,
+ ModuleType module_type,
+ const char* desc);
wabt::Result ReadUnlinkableModule(int line_number,
- string_view module_filename,
- ModuleType module_type,
- const char* desc);
+ string_view module_filename,
+ ModuleType module_type,
+ const char* desc);
Store store_;
- Registry registry_; // Used when importing.
+ Registry registry_; // Used when importing.
Registry instances_; // Used when referencing module by name in invoke.
ExportMap last_instance_;
int passed_ = 0;
@@ -1241,15 +1242,15 @@ CommandRunner::CommandRunner() : store_(s_features) {
for (auto&& print : print_funcs) {
auto import_name = StringPrintf("spectest.%s", print.name);
- spectest[print.name] = HostFunc::New(
- store_, print.type,
- [=](Thread& inst, const Values& params, Values& results,
- Trap::Ptr* trap) -> wabt::Result {
- printf("called host ");
- WriteCall(s_stdout_stream.get(), import_name, print.type, params,
- results, *trap);
- return wabt::Result::Ok;
- });
+ spectest[print.name] =
+ HostFunc::New(store_, print.type,
+ [=](Thread& inst, const Values& params, Values& results,
+ Trap::Ptr* trap) -> wabt::Result {
+ printf("called host ");
+ WriteCall(s_stdout_stream.get(), import_name,
+ print.type, params, results, *trap);
+ return wabt::Result::Ok;
+ });
}
spectest["table"] =
@@ -1257,14 +1258,18 @@ CommandRunner::CommandRunner() : store_(s_features) {
spectest["memory"] = interp::Memory::New(store_, MemoryType{Limits{1, 2}});
- spectest["global_i32"] = interp::Global::New(
- store_, GlobalType{ValueType::I32, Mutability::Const}, Value::Make(u32{666}));
- spectest["global_i64"] = interp::Global::New(
- store_, GlobalType{ValueType::I64, Mutability::Const}, Value::Make(u64{666}));
- spectest["global_f32"] = interp::Global::New(
- store_, GlobalType{ValueType::F32, Mutability::Const}, Value::Make(f32{666}));
- spectest["global_f64"] = interp::Global::New(
- store_, GlobalType{ValueType::F64, Mutability::Const}, Value::Make(f64{666}));
+ spectest["global_i32"] =
+ interp::Global::New(store_, GlobalType{ValueType::I32, Mutability::Const},
+ Value::Make(u32{666}));
+ spectest["global_i64"] =
+ interp::Global::New(store_, GlobalType{ValueType::I64, Mutability::Const},
+ Value::Make(u64{666}));
+ spectest["global_f32"] =
+ interp::Global::New(store_, GlobalType{ValueType::F32, Mutability::Const},
+ Value::Make(f32{666}));
+ spectest["global_f64"] =
+ interp::Global::New(store_, GlobalType{ValueType::F64, Mutability::Const},
+ Value::Make(f64{666}));
}
wabt::Result CommandRunner::Run(const Script& script) {
@@ -1377,7 +1382,7 @@ ActionResult CommandRunner::RunAction(int line_number,
}
wabt::Result CommandRunner::ReadInvalidTextModule(string_view module_filename,
- const std::string& header) {
+ const std::string& header) {
std::vector<uint8_t> file_data;
wabt::Result result = ReadFile(module_filename, &file_data);
std::unique_ptr<WastLexer> lexer = WastLexer::CreateBufferLexer(
@@ -1396,7 +1401,7 @@ wabt::Result CommandRunner::ReadInvalidTextModule(string_view module_filename,
}
interp::Module::Ptr CommandRunner::ReadModule(string_view module_filename,
- Errors* errors) {
+ Errors* errors) {
std::vector<uint8_t> file_data;
if (Failed(ReadFile(module_filename, &file_data))) {
@@ -1423,9 +1428,9 @@ interp::Module::Ptr CommandRunner::ReadModule(string_view module_filename,
}
wabt::Result CommandRunner::ReadInvalidModule(int line_number,
- string_view module_filename,
- ModuleType module_type,
- const char* desc) {
+ string_view module_filename,
+ ModuleType module_type,
+ const char* desc) {
std::string header = StringPrintf(
"%s:%d: %s passed", source_filename_.c_str(), line_number, desc);
@@ -1527,7 +1532,7 @@ wabt::Result CommandRunner::OnActionCommand(const ActionCommand* command) {
wabt::Result CommandRunner::OnAssertMalformedCommand(
const AssertMalformedCommand* command) {
wabt::Result result = ReadInvalidModule(command->line, command->filename,
- command->type, "assert_malformed");
+ command->type, "assert_malformed");
if (Succeeded(result)) {
PrintError(command->line, "expected module to be malformed: \"%s\"",
command->filename.c_str());
@@ -1583,7 +1588,7 @@ wabt::Result CommandRunner::OnAssertUnlinkableCommand(
wabt::Result CommandRunner::OnAssertInvalidCommand(
const AssertInvalidCommand* command) {
wabt::Result result = ReadInvalidModule(command->line, command->filename,
- command->type, "assert_invalid");
+ command->type, "assert_invalid");
if (Succeeded(result)) {
PrintError(command->line, "expected module to be invalid: \"%s\"",
command->filename.c_str());
diff --git a/src/tools/wasm-decompile.cc b/src/tools/wasm-decompile.cc
index 74491e55..df2bd2b5 100644
--- a/src/tools/wasm-decompile.cc
+++ b/src/tools/wasm-decompile.cc
@@ -20,8 +20,9 @@
#include <cstdlib>
#include "src/apply-names.h"
-#include "src/binary-reader.h"
#include "src/binary-reader-ir.h"
+#include "src/binary-reader.h"
+#include "src/decompiler.h"
#include "src/error-formatter.h"
#include "src/feature.h"
#include "src/generate-names.h"
@@ -30,7 +31,6 @@
#include "src/stream.h"
#include "src/validator.h"
#include "src/wast-lexer.h"
-#include "src/decompiler.h"
using namespace wabt;
@@ -45,12 +45,12 @@ int ProgramMain(int argc, char** argv) {
{
const char s_description[] =
- " Read a file in the WebAssembly binary format, and convert it to\n"
- " a decompiled text file.\n"
- "\n"
- "examples:\n"
- " # parse binary file test.wasm and write text file test.dcmp\n"
- " $ wasm-decompile test.wasm -o test.dcmp\n";
+ " Read a file in the WebAssembly binary format, and convert it to\n"
+ " a decompiled text file.\n"
+ "\n"
+ "examples:\n"
+ " # parse binary file test.wasm and write text file test.dcmp\n"
+ " $ wasm-decompile test.wasm -o test.dcmp\n";
OptionParser parser("wasm-decompile", s_description);
parser.AddOption(
'o', "output", "FILENAME",
@@ -77,8 +77,7 @@ int ProgramMain(int argc, char** argv) {
Errors errors;
Module module;
const bool kStopOnFirstError = true;
- ReadBinaryOptions options(features, nullptr,
- true, kStopOnFirstError,
+ ReadBinaryOptions options(features, nullptr, true, kStopOnFirstError,
fail_on_custom_section_error);
result = ReadBinaryIr(infile.c_str(), file_data.data(), file_data.size(),
options, &errors, &module);
@@ -86,8 +85,8 @@ int ProgramMain(int argc, char** argv) {
ValidateOptions options(features);
result = ValidateModule(&module, &errors, options);
if (Succeeded(result)) {
- result = GenerateNames(&module,
- static_cast<NameOpts>(NameOpts::AlphaNames));
+ result =
+ GenerateNames(&module, static_cast<NameOpts>(NameOpts::AlphaNames));
}
if (Succeeded(result)) {
// Must be called after ReadBinaryIr & GenerateNames, and before
@@ -103,7 +102,7 @@ int ProgramMain(int argc, char** argv) {
if (Succeeded(result)) {
auto s = Decompile(module, decompile_options);
FileStream stream(!outfile.empty() ? FileStream(outfile)
- : FileStream(stdout));
+ : FileStream(stdout));
stream.WriteData(s.data(), s.size());
}
}
diff --git a/src/tools/wasm-interp.cc b/src/tools/wasm-interp.cc
index c4d44ebe..465ad611 100644
--- a/src/tools/wasm-interp.cc
+++ b/src/tools/wasm-interp.cc
@@ -173,15 +173,14 @@ static void BindImports(const Module::Ptr& module, RefVec& imports) {
auto import_name = StringPrintf("%s.%s", import.type.module.c_str(),
import.type.name.c_str());
- auto host_func =
- HostFunc::New(s_store, func_type,
- [=](Thread& thread, const Values& params,
- Values& results, Trap::Ptr* trap) -> Result {
- printf("called host ");
- WriteCall(stream, import_name, func_type, params,
- results, *trap);
- return Result::Ok;
- });
+ auto host_func = HostFunc::New(
+ s_store, func_type,
+ [=](Thread& thread, const Values& params, Values& results,
+ Trap::Ptr* trap) -> Result {
+ printf("called host ");
+ WriteCall(stream, import_name, func_type, params, results, *trap);
+ return Result::Ok;
+ });
imports.push_back(host_func.ref());
continue;
}
diff --git a/src/tools/wasm-objdump.cc b/src/tools/wasm-objdump.cc
index fbfed12c..59060432 100644
--- a/src/tools/wasm-objdump.cc
+++ b/src/tools/wasm-objdump.cc
@@ -18,16 +18,16 @@
#include <cstdlib>
#include <cstring>
+#include "src/binary-reader-objdump.h"
+#include "src/binary-reader.h"
#include "src/common.h"
#include "src/option-parser.h"
#include "src/stream.h"
-#include "src/binary-reader.h"
-#include "src/binary-reader-objdump.h"
using namespace wabt;
static const char s_description[] =
-R"( Print information about the contents of wasm binaries.
+ R"( Print information about the contents of wasm binaries.
examples:
$ wasm-objdump test.wasm
@@ -133,7 +133,7 @@ int ProgramMain(int argc, char** argv) {
return 1;
}
- for (const char* filename: s_infiles) {
+ for (const char* filename : s_infiles) {
if (Failed(dump_file(filename))) {
return 1;
}
diff --git a/src/tools/wasm-opcodecnt.cc b/src/tools/wasm-opcodecnt.cc
index 5d6225f0..4df8598b 100644
--- a/src/tools/wasm-opcodecnt.cc
+++ b/src/tools/wasm-opcodecnt.cc
@@ -23,8 +23,8 @@
#include <map>
#include <vector>
-#include "src/binary-reader.h"
#include "src/binary-reader-opcnt.h"
+#include "src/binary-reader.h"
#include "src/option-parser.h"
#include "src/stream.h"
@@ -44,7 +44,7 @@ static std::unique_ptr<FileStream> s_log_stream;
static Features s_features;
static const char s_description[] =
-R"( Read a file in the wasm binary format, and count opcode usage for
+ R"( Read a file in the wasm binary format, and count opcode usage for
instructions.
examples:
@@ -85,9 +85,7 @@ struct SortByCountDescending {
template <typename T>
struct WithinCutoff {
- bool operator()(const T& pair) const {
- return pair.second >= s_cutoff;
- }
+ bool operator()(const T& pair) const { return pair.second >= s_cutoff; }
};
static size_t SumCounts(const OpcodeInfoCounts& info_counts) {
@@ -102,7 +100,7 @@ void WriteCounts(Stream& stream, const OpcodeInfoCounts& info_counts) {
typedef std::pair<Opcode, size_t> OpcodeCountPair;
std::map<Opcode, size_t> counts;
- for (auto& info_count_pair: info_counts) {
+ for (auto& info_count_pair : info_counts) {
Opcode opcode = info_count_pair.first.opcode();
size_t count = info_count_pair.second;
counts[opcode] += count;
@@ -124,8 +122,7 @@ void WriteCounts(Stream& stream, const OpcodeInfoCounts& info_counts) {
}
}
-void WriteCountsWithImmediates(Stream& stream,
- const OpcodeInfoCounts& counts) {
+void WriteCountsWithImmediates(Stream& stream, const OpcodeInfoCounts& counts) {
// Remove const from the key type so we can sort below.
typedef std::pair<std::remove_const<OpcodeInfoCounts::key_type>::type,
OpcodeInfoCounts::mapped_type>
diff --git a/src/tools/wasm-strip.cc b/src/tools/wasm-strip.cc
index 44915443..c8f3f83c 100644
--- a/src/tools/wasm-strip.cc
+++ b/src/tools/wasm-strip.cc
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#include "src/binary.h"
-#include "src/binary-reader.h"
#include "src/binary-reader-nop.h"
+#include "src/binary-reader.h"
+#include "src/binary.h"
#include "src/error-formatter.h"
#include "src/leb128.h"
#include "src/option-parser.h"
@@ -27,7 +27,7 @@ using namespace wabt;
static std::string s_filename;
static const char s_description[] =
-R"( Remove sections of a WebAssembly binary file.
+ R"( Remove sections of a WebAssembly binary file.
examples:
# Remove all custom sections from test.wasm
@@ -47,8 +47,7 @@ static void ParseOptions(int argc, char** argv) {
class BinaryReaderStrip : public BinaryReaderNop {
public:
- explicit BinaryReaderStrip(Errors* errors)
- : errors_(errors) {
+ explicit BinaryReaderStrip(Errors* errors) : errors_(errors) {
stream_.WriteU32(WABT_BINARY_MAGIC, "WASM_BINARY_MAGIC");
stream_.WriteU32(WABT_BINARY_VERSION, "WASM_BINARY_VERSION");
}
diff --git a/src/tools/wasm-validate.cc b/src/tools/wasm-validate.cc
index a55c5ed8..dd48e121 100644
--- a/src/tools/wasm-validate.cc
+++ b/src/tools/wasm-validate.cc
@@ -19,8 +19,8 @@
#include <cstdio>
#include <cstdlib>
-#include "src/binary-reader.h"
#include "src/binary-reader-ir.h"
+#include "src/binary-reader.h"
#include "src/error-formatter.h"
#include "src/ir.h"
#include "src/option-parser.h"
@@ -38,7 +38,7 @@ static bool s_fail_on_custom_section_error = true;
static std::unique_ptr<FileStream> s_log_stream;
static const char s_description[] =
-R"( Read a file in the WebAssembly binary format, and validate it.
+ R"( Read a file in the WebAssembly binary format, and validate it.
examples:
# validate binary file test.wasm
diff --git a/src/tools/wasm2c.cc b/src/tools/wasm2c.cc
index be96a819..a20b7e4b 100644
--- a/src/tools/wasm2c.cc
+++ b/src/tools/wasm2c.cc
@@ -45,7 +45,7 @@ static bool s_read_debug_names = true;
static std::unique_ptr<FileStream> s_log_stream;
static const char s_description[] =
-R"( Read a file in the WebAssembly binary format, and convert it to
+ R"( Read a file in the WebAssembly binary format, and convert it to
a C source file and header.
examples:
@@ -164,4 +164,3 @@ int main(int argc, char** argv) {
return ProgramMain(argc, argv);
WABT_CATCH_BAD_ALLOC_AND_EXIT
}
-
diff --git a/src/tools/wasm2wat.cc b/src/tools/wasm2wat.cc
index 58e89849..2c50fea7 100644
--- a/src/tools/wasm2wat.cc
+++ b/src/tools/wasm2wat.cc
@@ -20,8 +20,8 @@
#include <cstdlib>
#include "src/apply-names.h"
-#include "src/binary-reader.h"
#include "src/binary-reader-ir.h"
+#include "src/binary-reader.h"
#include "src/error-formatter.h"
#include "src/feature.h"
#include "src/generate-names.h"
@@ -46,7 +46,7 @@ static std::unique_ptr<FileStream> s_log_stream;
static bool s_validate = true;
static const char s_description[] =
-R"( Read a file in the WebAssembly binary format, and convert it to
+ R"( Read a file in the WebAssembly binary format, and convert it to
the WebAssembly text format.
examples:
diff --git a/src/tools/wast2json.cc b/src/tools/wast2json.cc
index a5c9a47d..0418c9a7 100644
--- a/src/tools/wast2json.cc
+++ b/src/tools/wast2json.cc
@@ -17,14 +17,14 @@
#include <cassert>
#include <cstdarg>
#include <cstdint>
-#include <cstdlib>
#include <cstdio>
+#include <cstdlib>
#include <string>
#include "config.h"
-#include "src/binary-writer.h"
#include "src/binary-writer-spec.h"
+#include "src/binary-writer.h"
#include "src/common.h"
#include "src/error-formatter.h"
#include "src/feature.h"
@@ -49,7 +49,7 @@ static Features s_features;
static std::unique_ptr<FileStream> s_log_stream;
static const char s_description[] =
-R"( read a file in the wasm spec test format, check it for errors, and
+ R"( read a file in the wasm spec test format, check it for errors, and
convert it to a JSON file and associated wasm binary files.
examples:
diff --git a/src/tools/wat-desugar.cc b/src/tools/wat-desugar.cc
index cc6a2cba..85c2d8a5 100644
--- a/src/tools/wat-desugar.cc
+++ b/src/tools/wat-desugar.cc
@@ -43,7 +43,7 @@ static bool s_debug_parsing;
static Features s_features;
static const char s_description[] =
-R"( read a file in the wasm s-expression format and format it.
+ R"( read a file in the wasm s-expression format and format it.
examples:
# write output to stdout
diff --git a/src/tools/wat2wasm.cc b/src/tools/wat2wasm.cc
index f77dad27..4a71b572 100644
--- a/src/tools/wat2wasm.cc
+++ b/src/tools/wat2wasm.cc
@@ -17,8 +17,8 @@
#include <cassert>
#include <cstdarg>
#include <cstdint>
-#include <cstdlib>
#include <cstdio>
+#include <cstdlib>
#include <string>
#include "config.h"
@@ -49,7 +49,7 @@ static Features s_features;
static std::unique_ptr<FileStream> s_log_stream;
static const char s_description[] =
-R"( read a file in the wasm text format, check it for errors, and
+ R"( read a file in the wasm text format, check it for errors, and
convert it to the wasm binary format.
examples:
diff --git a/src/type-checker.cc b/src/type-checker.cc
index 1f6fd24b..eb23446f 100644
--- a/src/type-checker.cc
+++ b/src/type-checker.cc
@@ -161,8 +161,9 @@ Result TypeChecker::CheckLabelType(Label* label, LabelType label_type) {
Result TypeChecker::Check2LabelTypes(Label* label,
LabelType label_type1,
LabelType label_type2) {
- return label->label_type == label_type1 ||
- label->label_type == label_type2 ? Result::Ok : Result::Error;
+ return label->label_type == label_type1 || label->label_type == label_type2
+ ? Result::Ok
+ : Result::Error;
}
Result TypeChecker::GetThisFunctionLabel(Label** label) {
@@ -911,7 +912,9 @@ Result TypeChecker::OnSimdLaneOp(Opcode opcode, uint64_t lane_idx) {
return result;
}
-Result TypeChecker::OnSimdLoadLane(Opcode opcode, const Limits& limits, uint64_t lane_idx) {
+Result TypeChecker::OnSimdLoadLane(Opcode opcode,
+ const Limits& limits,
+ uint64_t lane_idx) {
Result result = Result::Ok;
uint32_t lane_count = opcode.GetSimdLaneCount();
if (lane_idx >= lane_count) {
@@ -923,7 +926,9 @@ Result TypeChecker::OnSimdLoadLane(Opcode opcode, const Limits& limits, uint64_t
return result;
}
-Result TypeChecker::OnSimdStoreLane(Opcode opcode, const Limits& limits, uint64_t lane_idx) {
+Result TypeChecker::OnSimdStoreLane(Opcode opcode,
+ const Limits& limits,
+ uint64_t lane_idx) {
Result result = Result::Ok;
uint32_t lane_count = opcode.GetSimdLaneCount();
if (lane_idx >= lane_count) {
diff --git a/src/type-checker.h b/src/type-checker.h
index 8794f837..73ac5fb8 100644
--- a/src/type-checker.h
+++ b/src/type-checker.h
@@ -79,8 +79,10 @@ class TypeChecker {
Result OnCallIndirect(const TypeVector& param_types,
const TypeVector& result_types);
Result OnIndexedFuncRef(Index* out_index);
- Result OnReturnCall(const TypeVector& param_types, const TypeVector& result_types);
- Result OnReturnCallIndirect(const TypeVector& param_types, const TypeVector& result_types);
+ Result OnReturnCall(const TypeVector& param_types,
+ const TypeVector& result_types);
+ Result OnReturnCallIndirect(const TypeVector& param_types,
+ const TypeVector& result_types);
Result OnCatch(const TypeVector& sig);
Result OnCompare(Opcode);
Result OnConst(Type);
@@ -144,17 +146,21 @@ class TypeChecker {
const TypeVector& result_types);
Result PopLabel();
Result CheckLabelType(Label* label, LabelType label_type);
- Result Check2LabelTypes(Label* label, LabelType label_type1, LabelType label_type2);
- Result GetThisFunctionLabel(Label **label);
+ Result Check2LabelTypes(Label* label,
+ LabelType label_type1,
+ LabelType label_type2);
+ Result GetThisFunctionLabel(Label** label);
Result PeekType(Index depth, Type* out_type);
Result PeekAndCheckType(Index depth, Type expected);
Result DropTypes(size_t drop_count);
void PushType(Type type);
void PushTypes(const TypeVector& types);
Result CheckTypeStackEnd(const char* desc);
- Result CheckTypes(const TypeVector &actual, const TypeVector &expected);
+ Result CheckTypes(const TypeVector& actual, const TypeVector& expected);
Result CheckSignature(const TypeVector& sig, const char* desc);
- Result CheckReturnSignature(const TypeVector& sig, const TypeVector &expected,const char *desc);
+ Result CheckReturnSignature(const TypeVector& sig,
+ const TypeVector& expected,
+ const char* desc);
Result PopAndCheckSignature(const TypeVector& sig, const char* desc);
Result PopAndCheckCall(const TypeVector& param_types,
const TypeVector& result_types,
diff --git a/src/type.h b/src/type.h
index 64c71c7e..d9b662aa 100644
--- a/src/type.h
+++ b/src/type.h
@@ -120,7 +120,7 @@ class Type {
// (type $T (func (result i32 i64)))
// ...
// (block (type $T) ...)
- //
+ //
bool IsIndex() const { return static_cast<int32_t>(enum_) >= 0; }
Index GetIndex() const {
diff --git a/src/utf8.cc b/src/utf8.cc
index 37a8df00..f3ca98e4 100644
--- a/src/utf8.cc
+++ b/src/utf8.cc
@@ -22,6 +22,7 @@ namespace wabt {
namespace {
+// clang-format off
const int s_utf8_length[256] = {
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00
@@ -41,6 +42,7 @@ const int s_utf8_length[256] = {
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0
4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0
};
+// clang-format on
// Returns true if this is a valid continuation byte.
bool IsCont(uint8_t c) {
diff --git a/src/validator.cc b/src/validator.cc
index 610170f9..f662b3b0 100644
--- a/src/validator.cc
+++ b/src/validator.cc
@@ -507,8 +507,7 @@ Result Validator::BeginTryExpr(TryExpr* expr) {
}
Result Validator::OnCatchExpr(TryExpr*, Catch* catch_) {
- result_ |= validator_.OnCatch(catch_->loc, catch_->var,
- catch_->IsCatchAll());
+ result_ |= validator_.OnCatch(catch_->loc, catch_->var, catch_->IsCatchAll());
return Result::Ok;
}
@@ -584,9 +583,9 @@ Result Validator::OnSimdLaneOpExpr(SimdLaneOpExpr* expr) {
}
Result Validator::OnSimdLoadLaneExpr(SimdLoadLaneExpr* expr) {
- result_ |= validator_.OnSimdLoadLane(
- expr->loc, expr->opcode, expr->opcode.GetAlignment(expr->align),
- expr->val);
+ result_ |= validator_.OnSimdLoadLane(expr->loc, expr->opcode,
+ expr->opcode.GetAlignment(expr->align),
+ expr->val);
return Result::Ok;
}
@@ -828,8 +827,8 @@ Result Validator::CheckModule() {
// Data segment section.
for (const ModuleField& field : module->fields) {
if (auto* f = dyn_cast<DataSegmentModuleField>(&field)) {
- result_ |= validator_.OnDataSegment(
- field.loc, f->data_segment.memory_var, f->data_segment.kind);
+ result_ |= validator_.OnDataSegment(field.loc, f->data_segment.memory_var,
+ f->data_segment.kind);
// Init expr.
if (f->data_segment.offset.size()) {
diff --git a/src/validator.h b/src/validator.h
index b84acbc9..23ba72c1 100644
--- a/src/validator.h
+++ b/src/validator.h
@@ -33,4 +33,4 @@ Result ValidateModule(const Module*, Errors*, const ValidateOptions&);
} // namespace wabt
-#endif // WABT_VALIDATOR_H_
+#endif // WABT_VALIDATOR_H_
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index 40446e47..40264cc0 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -496,7 +496,7 @@ Result ResolveFuncTypes(Module* module, Errors* errors) {
// local variables share the same index space, we need to increment the
// local indexes bound to a given name by the number of parameters in
// the function.
- for (auto& pair: func->bindings) {
+ for (auto& pair : func->bindings) {
pair.second.index += func->GetNumParams();
}
}
@@ -1966,8 +1966,8 @@ Result WastParser::ParseSimdLane(Location loc, uint64_t* lane_idx) {
Literal literal = Consume().literal();
- Result result = ParseInt64(literal.text.begin(), literal.text.end(),
- lane_idx, ParseIntType::UnsignedOnly);
+ Result result = ParseInt64(literal.text.begin(), literal.text.end(), lane_idx,
+ ParseIntType::UnsignedOnly);
if (Failed(result)) {
Error(loc, "invalid literal \"" PRIstringview "\"",
@@ -2361,7 +2361,8 @@ Result WastParser::ParsePlainInstr(std::unique_ptr<Expr>* out_expr) {
return Result::Error;
}
- out_expr->reset(new SimdLoadLaneExpr(token.opcode(), align, offset, lane_idx, loc));
+ out_expr->reset(
+ new SimdLoadLaneExpr(token.opcode(), align, offset, lane_idx, loc));
break;
}
@@ -2381,7 +2382,8 @@ Result WastParser::ParsePlainInstr(std::unique_ptr<Expr>* out_expr) {
return Result::Error;
}
- out_expr->reset(new SimdStoreLaneExpr(token.opcode(), align, offset, lane_idx, loc));
+ out_expr->reset(
+ new SimdStoreLaneExpr(token.opcode(), align, offset, lane_idx, loc));
break;
}
@@ -2400,8 +2402,7 @@ Result WastParser::ParsePlainInstr(std::unique_ptr<Expr>* out_expr) {
values.set_u8(lane, static_cast<uint8_t>(lane_idx));
}
- out_expr->reset(
- new SimdShuffleOpExpr(token.opcode(), values, loc));
+ out_expr->reset(new SimdShuffleOpExpr(token.opcode(), values, loc));
break;
}
@@ -2429,13 +2430,11 @@ Result WastParser::ParseSimdV128Const(Const* const_,
case TokenType::F32X4: { lane_count = 4; integer = false; break; }
case TokenType::F64X2: { lane_count = 2; integer = false; break; }
default: {
- Error(
- const_->loc,
- "Unexpected type at start of simd constant. "
- "Expected one of: i8x16, i16x8, i32x4, i64x2, f32x4, f64x2. "
- "Found \"%s\".",
- GetTokenTypeName(token_type)
- );
+ Error(const_->loc,
+ "Unexpected type at start of simd constant. "
+ "Expected one of: i8x16, i16x8, i32x4, i64x2, f32x4, f64x2. "
+ "Found \"%s\".",
+ GetTokenTypeName(token_type));
return Result::Error;
}
}
@@ -3255,7 +3254,7 @@ Result WastParser::ParseModuleCommand(Script* script, CommandPtr* out_command) {
&errors, &module);
module.name = bsm->name;
module.loc = bsm->loc;
- for (const auto& error: errors) {
+ for (const auto& error : errors) {
assert(error.error_level == ErrorLevel::Error);
if (error.loc.offset == kInvalidOffset) {
Error(bsm->loc, "error in binary module: %s", error.message.c_str());
diff --git a/src/wat-writer.cc b/src/wat-writer.cc
index 289e66d8..701134ce 100644
--- a/src/wat-writer.cc
+++ b/src/wat-writer.cc
@@ -30,8 +30,8 @@
#include "src/cast.h"
#include "src/common.h"
#include "src/expr-visitor.h"
-#include "src/ir.h"
#include "src/ir-util.h"
+#include "src/ir.h"
#include "src/literal.h"
#include "src/stream.h"
@@ -91,8 +91,9 @@ struct ExprTree {
class WatWriter : ModuleContext {
public:
- WatWriter(Stream* stream, const WriteWatOptions& options,
- const Module &module)
+ WatWriter(Stream* stream,
+ const WriteWatOptions& options,
+ const Module& module)
: ModuleContext(module), options_(options), stream_(stream) {}
Result WriteModule();
@@ -674,8 +675,7 @@ Result WatWriter::ExprVisitorDelegate::OnCallIndirectExpr(
return Result::Ok;
}
-Result WatWriter::ExprVisitorDelegate::OnCallRefExpr(
- CallRefExpr* expr) {
+Result WatWriter::ExprVisitorDelegate::OnCallRefExpr(CallRefExpr* expr) {
writer_->WritePutsSpace(Opcode::CallRef_Opcode.GetName());
return Result::Ok;
}
@@ -936,8 +936,8 @@ Result WatWriter::ExprVisitorDelegate::BeginTryExpr(TryExpr* expr) {
return Result::Ok;
}
-Result WatWriter::ExprVisitorDelegate::OnCatchExpr(
- TryExpr* expr, Catch* catch_) {
+Result WatWriter::ExprVisitorDelegate::OnCatchExpr(TryExpr* expr,
+ Catch* catch_) {
writer_->Dedent();
if (catch_->IsCatchAll()) {
writer_->WritePutsNewline(Opcode::CatchAll_Opcode.GetName());
@@ -1027,7 +1027,8 @@ Result WatWriter::ExprVisitorDelegate::OnSimdLaneOpExpr(SimdLaneOpExpr* expr) {
return Result::Ok;
}
-Result WatWriter::ExprVisitorDelegate::OnSimdLoadLaneExpr(SimdLoadLaneExpr* expr) {
+Result WatWriter::ExprVisitorDelegate::OnSimdLoadLaneExpr(
+ SimdLoadLaneExpr* expr) {
writer_->WritePutsSpace(expr->opcode.GetName());
if (expr->offset) {
writer_->Writef("offset=%" PRIaddress, expr->offset);