[Tarantool-patches] [PATCH 0/3] Add clang format

Kirill Yukhin kyukhin at tarantool.org
Wed Oct 7 16:24:07 MSK 2020


Hello,

This set of 3 patches apply custom clang format rules
which look more or less close to our coding guideline.

First one blocks some artistic plases in constants declarations.
Second adds custom clang format file.
Third was derived by appliyng it:
  /src/box$ find . -iname \*.h -o -iname \*.c -o -iname \*.cc |grep -v sql |xargs clang-format -i

NB: I was playing with clang v11, but hope this will work
with clang 8

Documentation for clang-format style options is here [1].

It'd be great to hear inputs like clang-format file improvements.

If we'll agree, next steps would be:
  1. Add cmake rule, which will allow to run formatter against
     the source tree.
  2. Add new CI job, which will execute formatter on each commit.
  3. Add formatter for SQL subsytem.
  4. Extend formatter out of box/ folder (questionable)

[1] - https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Issue: https://github.com/tarantool/tarantool/issues/4297
Branch: https://github.com/tarantool/tarantool/tree/kyukhin/gh-4297-clang-format

Kirill Yukhin (3):
  clang-format: guard various declarations
  Add .clang-format for src/box/
  Apply clang-format

 src/box/.clang-format         |  125 ++++
 src/box/alter.cc              | 1565 ++++++++++++++++++++---------------------
 src/box/applier.cc            |  140 ++--
 src/box/applier.h             |   36 +-
 src/box/authentication.cc     |    8 +-
 src/box/authentication.h      |    1 -
 src/box/bind.c                |   13 +-
 src/box/bind.h                |    3 +-
 src/box/blackhole.c           |   15 +-
 src/box/box.cc                |  192 +++--
 src/box/box.h                 |  104 ++-
 src/box/call.c                |    9 +-
 src/box/checkpoint_schedule.c |    4 +-
 src/box/checkpoint_schedule.h |    4 +-
 src/box/ck_constraint.c       |   21 +-
 src/box/ck_constraint.h       |    4 +-
 src/box/coll_id.c             |    2 +-
 src/box/coll_id_cache.c       |    9 +-
 src/box/coll_id_def.c         |   17 +-
 src/box/column_mask.h         |    8 +-
 src/box/constraint_id.c       |    8 +-
 src/box/engine.c              |   56 +-
 src/box/engine.h              |   84 ++-
 src/box/errcode.c             |   11 +-
 src/box/errcode.h             |    4 +-
 src/box/error.cc              |   83 ++-
 src/box/error.h               |   86 +--
 src/box/execute.c             |   98 ++-
 src/box/field_def.c           |   28 +-
 src/box/field_def.h           |    2 +-
 src/box/field_map.c           |   17 +-
 src/box/field_map.h           |   12 +-
 src/box/fk_constraint.h       |    5 +-
 src/box/func.c                |   58 +-
 src/box/func.h                |    3 +-
 src/box/func_def.c            |   25 +-
 src/box/func_def.h            |    4 +-
 src/box/gc.c                  |   38 +-
 src/box/identifier.c          |    6 +-
 src/box/index.cc              |  118 ++--
 src/box/index.h               |  135 ++--
 src/box/index_def.c           |   46 +-
 src/box/index_def.h           |   22 +-
 src/box/iproto.cc             |  220 +++---
 src/box/iproto_constants.c    |    4 +
 src/box/iproto_constants.h    |   26 +-
 src/box/iterator_type.c       |    3 +-
 src/box/iterator_type.h       |   29 +-
 src/box/journal.c             |    6 +-
 src/box/journal.h             |   23 +-
 src/box/key_def.c             |  114 ++-
 src/box/key_def.h             |   62 +-
 src/box/key_list.c            |    8 +-
 src/box/key_list.h            |    4 +-
 src/box/lua/call.c            |  104 ++-
 src/box/lua/call.h            |    8 +-
 src/box/lua/cfg.cc            |   92 ++-
 src/box/lua/console.c         |  112 +--
 src/box/lua/ctl.c             |   14 +-
 src/box/lua/error.cc          |   35 +-
 src/box/lua/execute.c         |   55 +-
 src/box/lua/index.c           |   75 +-
 src/box/lua/info.c            |   85 +--
 src/box/lua/init.c            |  110 ++-
 src/box/lua/key_def.c         |   52 +-
 src/box/lua/merger.c          |  178 +++--
 src/box/lua/misc.cc           |   41 +-
 src/box/lua/net_box.c         |   95 ++-
 src/box/lua/sequence.c        |   12 +-
 src/box/lua/serialize_lua.c   |  197 +++---
 src/box/lua/session.c         |   68 +-
 src/box/lua/slab.c            |   17 +-
 src/box/lua/slab.h            |    3 +-
 src/box/lua/space.cc          |   81 +--
 src/box/lua/stat.c            |   36 +-
 src/box/lua/stat.h            |    3 +-
 src/box/lua/tuple.c           |  102 ++-
 src/box/lua/xlog.c            |   38 +-
 src/box/memtx_bitset.c        |   70 +-
 src/box/memtx_engine.c        |  109 ++-
 src/box/memtx_engine.h        |   18 +-
 src/box/memtx_hash.c          |  142 ++--
 src/box/memtx_rtree.c         |   59 +-
 src/box/memtx_space.c         |  188 +++--
 src/box/memtx_space.h         |    4 +-
 src/box/memtx_tree.c          |  274 ++++----
 src/box/memtx_tx.c            |  141 ++--
 src/box/memtx_tx.h            |    4 +-
 src/box/merger.c              |    9 +-
 src/box/mp_error.cc           |   80 +--
 src/box/msgpack.c             |    4 +-
 src/box/opt_def.c             |   10 +-
 src/box/opt_def.h             |   72 +-
 src/box/port.h                |    6 +-
 src/box/raft.c                |   31 +-
 src/box/recovery.cc           |   40 +-
 src/box/recovery.h            |    2 +-
 src/box/relay.cc              |   71 +-
 src/box/relay.h               |    2 +-
 src/box/replication.cc        |  121 ++--
 src/box/replication.h         |   11 +-
 src/box/request.c             |   14 +-
 src/box/schema.cc             |  158 ++---
 src/box/schema.h              |   17 +-
 src/box/schema_def.c          |    6 +-
 src/box/schema_def.h          |    6 +-
 src/box/sequence.c            |   55 +-
 src/box/service_engine.c      |   10 +-
 src/box/session.cc            |   38 +-
 src/box/session.h             |    9 +-
 src/box/session_settings.c    |   34 +-
 src/box/space.c               |   86 +--
 src/box/space.h               |   87 ++-
 src/box/space_def.c           |   29 +-
 src/box/space_def.h           |   16 +-
 src/box/sysview.c             |   53 +-
 src/box/tuple.c               |  105 +--
 src/box/tuple.h               |   32 +-
 src/box/tuple_bloom.c         |   37 +-
 src/box/tuple_bloom.h         |    5 +-
 src/box/tuple_compare.cc      |  398 +++++------
 src/box/tuple_convert.c       |   28 +-
 src/box/tuple_dictionary.c    |   37 +-
 src/box/tuple_extract_key.cc  |   94 +--
 src/box/tuple_format.c        |  216 +++---
 src/box/tuple_format.h        |   34 +-
 src/box/tuple_hash.cc         |  140 ++--
 src/box/txn.c                 |   66 +-
 src/box/txn_limbo.c           |   34 +-
 src/box/user.cc               |  101 ++-
 src/box/user.h                |    5 +-
 src/box/user_def.c            |   23 +-
 src/box/user_def.h            |    6 +-
 src/box/vclock.c              |  151 ++--
 src/box/vclock.h              |   25 +-
 src/box/vinyl.c               |  388 +++++-----
 src/box/vinyl.h               |   12 +-
 src/box/vy_cache.c            |   65 +-
 src/box/vy_cache.h            |   10 +-
 src/box/vy_history.c          |    8 +-
 src/box/vy_history.h          |    8 +-
 src/box/vy_log.c              |  226 +++---
 src/box/vy_log.h              |   52 +-
 src/box/vy_lsm.c              |  184 ++---
 src/box/vy_lsm.h              |   18 +-
 src/box/vy_mem.c              |   91 ++-
 src/box/vy_mem.h              |   13 +-
 src/box/vy_point_lookup.c     |   41 +-
 src/box/vy_point_lookup.h     |    4 +-
 src/box/vy_quota.c            |   13 +-
 src/box/vy_quota.h            |    7 +-
 src/box/vy_range.c            |   22 +-
 src/box/vy_range.h            |    4 +-
 src/box/vy_read_iterator.c    |  136 ++--
 src/box/vy_read_set.c         |   11 +-
 src/box/vy_regulator.c        |   40 +-
 src/box/vy_regulator.h        |    7 +-
 src/box/vy_run.c              |  375 +++++-----
 src/box/vy_run.h              |   48 +-
 src/box/vy_scheduler.c        |  182 ++---
 src/box/vy_scheduler.h        |    6 +-
 src/box/vy_stmt.c             |  119 ++--
 src/box/vy_stmt.h             |   84 +--
 src/box/vy_stmt_stream.h      |   10 +-
 src/box/vy_tx.c               |  128 ++--
 src/box/vy_tx.h               |   21 +-
 src/box/vy_upsert.c           |   39 +-
 src/box/vy_upsert.h           |    4 +-
 src/box/vy_write_iterator.c   |   74 +-
 src/box/vy_write_iterator.h   |   11 +-
 src/box/wal.c                 |  185 +++--
 src/box/wal.h                 |    8 +-
 src/box/xlog.c                |  289 ++++----
 src/box/xlog.h                |   36 +-
 src/box/xrow.c                |  361 +++++-----
 src/box/xrow.h                |   44 +-
 src/box/xrow_io.cc            |   16 +-
 src/box/xrow_io.h             |    1 -
 src/box/xrow_update.c         |   65 +-
 src/box/xrow_update.h         |   12 +-
 src/box/xrow_update_array.c   |   89 +--
 src/box/xrow_update_bar.c     |   68 +-
 src/box/xrow_update_field.c   |  104 +--
 src/box/xrow_update_field.h   |  132 ++--
 src/box/xrow_update_map.c     |   84 +--
 src/box/xrow_update_route.c   |   45 +-
 186 files changed, 6470 insertions(+), 6494 deletions(-)
 create mode 100644 src/box/.clang-format

-- 
1.8.3.1



More information about the Tarantool-patches mailing list