summaryrefslogtreecommitdiff
path: root/src/ir.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/ir.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/ir.cc')
-rw-r--r--src/ir.cc127
1 files changed, 63 insertions, 64 deletions
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