summaryrefslogtreecommitdiff
path: root/src/validator.cc
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 /src/validator.cc
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.
Diffstat (limited to 'src/validator.cc')
-rw-r--r--src/validator.cc13
1 files changed, 6 insertions, 7 deletions
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()) {