diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-12-20 19:35:01 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-20 19:35:01 -0800 |
commit | e59cf9369004a521814222afbc05ae6b59446cd5 (patch) | |
tree | d1a0483a4e6ec6334182a42bf1d0a532f9e3b8e9 /src/tools/spectest-interp.cc | |
parent | 8b92c44494ea3c03b38c12275098b682071b6101 (diff) | |
download | wabt-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.
Diffstat (limited to 'src/tools/spectest-interp.cc')
-rw-r--r-- | src/tools/spectest-interp.cc | 71 |
1 files changed, 38 insertions, 33 deletions
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()); |