diff --git a/.clang-format b/.clang-format index 9243c9a2b21..0f20ca442ce 100644 --- a/.clang-format +++ b/.clang-format @@ -21,6 +21,7 @@ BinPackArguments: true BinPackParameters: true BraceWrapping: AfterClass: true + AfterCaseLabel: true AfterControlStatement: true AfterEnum: true AfterFunction: true diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index dcfb8d5e886..6aa7cebb7ca 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -28,11 +28,14 @@ jobs: with: python-version: '3.x' - # C format: clang-format-8 + # C format: clang-format-16 # Python format: yapf==0.22.0 - name: Install packages run: | - sudo apt-get install -y clang-format-8 + sudo apt-get install -y gnupg2 software-properties-common + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main" + sudo apt-get update && sudo apt-get install -qqy clang-format-16 python -m pip install --upgrade pip pip install yapf==0.22.0 diff --git a/compiler/circle-opselector/src/OpSelector.cpp b/compiler/circle-opselector/src/OpSelector.cpp index a7c3396ceca..f0cd0542bcc 100644 --- a/compiler/circle-opselector/src/OpSelector.cpp +++ b/compiler/circle-opselector/src/OpSelector.cpp @@ -68,7 +68,7 @@ bool is_number(const std::vector &vec) { for (const auto &s : vec) { - if (not::is_number(s)) + if (not ::is_number(s)) { return false; } @@ -270,7 +270,7 @@ OpSelector::select_by(const std::vector &comma_toke for (const auto &comma_token : comma_tokens) { auto dash_tokens = ::split_into_vector(comma_token, '-'); - if (not::is_number(dash_tokens)) + if (not ::is_number(dash_tokens)) { throw std::runtime_error{ "ERROR: To select operator by id, please use these args: [0-9], '-', ','"}; diff --git a/compiler/loco/include/loco/IR/NodePool.h b/compiler/loco/include/loco/IR/NodePool.h index 4db4caae376..77823c5a583 100644 --- a/compiler/loco/include/loco/IR/NodePool.h +++ b/compiler/loco/include/loco/IR/NodePool.h @@ -34,7 +34,7 @@ class NodePool final : public ObjectPool ~NodePool(); public: - template Derived *create(Args &&... args) + template Derived *create(Args &&...args) { std::unique_ptr ptr{new Derived(std::forward(args)...)}; ptr->graph(_graph); diff --git a/compiler/loco/src/IR/MockupNode.h b/compiler/loco/src/IR/MockupNode.h index 16eaccf3624..45a231d30ab 100644 --- a/compiler/loco/src/IR/MockupNode.h +++ b/compiler/loco/src/IR/MockupNode.h @@ -46,7 +46,7 @@ class MockupNode final : public loco::Node Node *arg(uint32_t N) const final { return _arg.node(); } void drop(void) final { _arg.node(nullptr); } - Node *in(void)const { return _arg.node(); } + Node *in(void) const { return _arg.node(); } void in(Node *node) { _arg.node(node); } private: diff --git a/compiler/loco/src/Service/GraphBuilder.h b/compiler/loco/src/Service/GraphBuilder.h index 74eed2af80b..f3015205cce 100644 --- a/compiler/loco/src/Service/GraphBuilder.h +++ b/compiler/loco/src/Service/GraphBuilder.h @@ -87,7 +87,7 @@ class GraphBuilder final public: // "Layer" is in theory a subgraph builder. template - auto push(Args &&... args) + auto push(Args &&...args) -> decltype(static_cast(nullptr)->operator()(static_cast(nullptr))) { Layer layer{std::forward(args)...}; diff --git a/compiler/luci-interpreter/src/loader/KernelBuilder.test.cpp b/compiler/luci-interpreter/src/loader/KernelBuilder.test.cpp index 135800fc790..128d1a43a31 100644 --- a/compiler/luci-interpreter/src/loader/KernelBuilder.test.cpp +++ b/compiler/luci-interpreter/src/loader/KernelBuilder.test.cpp @@ -103,7 +103,7 @@ class KernelBuilderTest : public Test std::unique_ptr _memory_manager; - template NodeT *createNode(Args &&... args) + template NodeT *createNode(Args &&...args) { auto *node = _graph.nodes()->create(std::forward(args)...); // The actual type does not matter for the purpose of the tests. diff --git a/compiler/luci/lang/include/luci/IR/SparsityParam.h b/compiler/luci/lang/include/luci/IR/SparsityParam.h index 6cfff67e1d9..15ddeb17cff 100644 --- a/compiler/luci/lang/include/luci/IR/SparsityParam.h +++ b/compiler/luci/lang/include/luci/IR/SparsityParam.h @@ -202,8 +202,8 @@ class DimMetaData } DimMetaData(DimensionType format, int32_t dense_size, const SparseIndexVector &array_segments, const SparseIndexVector &array_indices) - : _format{format}, _dense_size{dense_size}, _array_segments{array_segments}, _array_indices{ - array_indices} + : _format{format}, _dense_size{dense_size}, _array_segments{array_segments}, + _array_indices{array_indices} { // DO NOTHING } diff --git a/compiler/luci/pass/include/luci/CircleQuantizer.h b/compiler/luci/pass/include/luci/CircleQuantizer.h index ae3ab6ff109..a326c983685 100644 --- a/compiler/luci/pass/include/luci/CircleQuantizer.h +++ b/compiler/luci/pass/include/luci/CircleQuantizer.h @@ -47,7 +47,7 @@ class CircleQuantizer final public: // some helper methods size_t size(void) const { return items.size(); } - template void emplace_back(Args &&... args) { items.emplace_back(args...); } + template void emplace_back(Args &&...args) { items.emplace_back(args...); } std::vector::iterator begin() { return items.begin(); }; std::vector::iterator end() { return items.end(); }; diff --git a/compiler/mir-interpreter/src/ops/Common.h b/compiler/mir-interpreter/src/ops/Common.h index 43336216e0d..f7edf44ab32 100644 --- a/compiler/mir-interpreter/src/ops/Common.h +++ b/compiler/mir-interpreter/src/ops/Common.h @@ -27,7 +27,7 @@ namespace mir_interpreter { template