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/utf8.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/utf8.cc')
-rw-r--r-- | src/utf8.cc | 2 |
1 files changed, 2 insertions, 0 deletions
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) { |