You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/05/17 11:28:20 UTC

[incubator-doris] branch master updated: [code format]Upgrade clang-format in BE Code Formatter from 8 to 13 (#9602)

This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new ec2cd0083a [code format]Upgrade clang-format in BE Code Formatter from 8 to 13 (#9602)
ec2cd0083a is described below

commit ec2cd0083aa6740a0683a71b2b06c9e8772bc82e
Author: Adonis Ling <ad...@gmail.com>
AuthorDate: Tue May 17 19:28:15 2022 +0800

    [code format]Upgrade clang-format in BE Code Formatter from 8 to 13 (#9602)
---
 .github/workflows/clang-format.yml                |  2 +-
 be/src/exprs/table_function/explode_json_array.h  |  7 +++----
 be/src/olap/rowset/segment_v2/binary_plain_page.h |  3 ++-
 be/src/vec/common/cow.h                           |  4 ++--
 be/test/util/threadpool_test.cpp                  |  2 +-
 docs/en/developer-guide/cpp-format-code.md        | 15 ++++++++++-----
 docs/zh-CN/developer-guide/cpp-format-code.md     | 16 +++++++++++-----
 7 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml
index 372d7bcc33..a8f9e61677 100644
--- a/.github/workflows/clang-format.yml
+++ b/.github/workflows/clang-format.yml
@@ -36,5 +36,5 @@ jobs:
         id: be_clang_format
         with:
           source: 'be/src be/test'
-          clangFormatVersion: 10
+          clangFormatVersion: 13
           inplace: False
diff --git a/be/src/exprs/table_function/explode_json_array.h b/be/src/exprs/table_function/explode_json_array.h
index d98c56d929..616535ea12 100644
--- a/be/src/exprs/table_function/explode_json_array.h
+++ b/be/src/exprs/table_function/explode_json_array.h
@@ -87,10 +87,9 @@ struct ParsedData {
             *output = _data[offset];
             break;
         case ExplodeJsonArrayType::STRING:
-            *output = _string_nulls[offset]
-                              ? nullptr
-                              : real ? reinterpret_cast<void*>(_backup_string[offset].data())
-                                     : &_data_string[offset];
+            *output = _string_nulls[offset] ? nullptr
+                      : real                ? reinterpret_cast<void*>(_backup_string[offset].data())
+                                            : &_data_string[offset];
             break;
         default:
             CHECK(false) << type;
diff --git a/be/src/olap/rowset/segment_v2/binary_plain_page.h b/be/src/olap/rowset/segment_v2/binary_plain_page.h
index e8c8f2a18e..58dad51b90 100644
--- a/be/src/olap/rowset/segment_v2/binary_plain_page.h
+++ b/be/src/olap/rowset/segment_v2/binary_plain_page.h
@@ -271,7 +271,8 @@ public:
     }
 
     void get_dict_word_info(StringRef* dict_word_info) {
-        if (_num_elems <= 0) [[unlikely]] return;
+        if (_num_elems <= 0) [[unlikely]]
+            return;
 
         char* data_begin = (char*)&_data[0];
         char* offset_ptr = (char*)&_data[_offsets_pos];
diff --git a/be/src/vec/common/cow.h b/be/src/vec/common/cow.h
index 3cefc293b2..27f3e864a6 100644
--- a/be/src/vec/common/cow.h
+++ b/be/src/vec/common/cow.h
@@ -350,8 +350,8 @@ protected:
         const T& operator*() const { return *value; }
         T& operator*() { return value->assume_mutable_ref(); }
 
-        operator const immutable_ptr<T> &() const { return value; }
-        operator immutable_ptr<T> &() { return value; }
+        operator const immutable_ptr<T>&() const { return value; }
+        operator immutable_ptr<T>&() { return value; }
 
         operator bool() const { return value != nullptr; }
         bool operator!() const { return value == nullptr; }
diff --git a/be/test/util/threadpool_test.cpp b/be/test/util/threadpool_test.cpp
index 33c9fe3817..eceda73f55 100644
--- a/be/test/util/threadpool_test.cpp
+++ b/be/test/util/threadpool_test.cpp
@@ -236,7 +236,7 @@ TEST_F(ThreadPoolTest, TestRace) {
         // so an cast is needed to use std::bind
         EXPECT_TRUE(_pool
                             ->submit_func(std::bind(
-                                    (void (CountDownLatch::*)())(&CountDownLatch::count_down), &l))
+                                    (void(CountDownLatch::*)())(&CountDownLatch::count_down), &l))
                             .ok());
         l.wait();
         // Sleeping a different amount in each iteration makes it more likely to hit
diff --git a/docs/en/developer-guide/cpp-format-code.md b/docs/en/developer-guide/cpp-format-code.md
index 9d5e7ca6c7..173ff0cac5 100644
--- a/docs/en/developer-guide/cpp-format-code.md
+++ b/docs/en/developer-guide/cpp-format-code.md
@@ -40,7 +40,7 @@ Doris uses clang-format for code formatting, and provides a package script in th
 
 The code style of Doris is slightly modified on the basis of Google Style and is customized as a `.clang-format` file located in the root directory of Doris.
 
-Currently, the `.clang-format` configuration file is adapted to versions above clang-format-8.0.1.
+Currently, the `.clang-format` configuration file is adapted to versions above clang-format-13.0.1.
 
 The code that you do not want to be formatted is recorded in the `.clang-format-ignore` file. These codes usually come from third-party code bases, and it is recommended to keep the original code style.
 
@@ -50,19 +50,24 @@ You need to download and install clang-format, or you can use the clang-format p
 
 ### Download and install clang-format
 
-It is recommended to use NPM to install clang-format 11 (different versions of clang-format may produce different code formats, it is recommended to use version 11):
+It is recommended to use NPM to install clang-format 14 (different versions of clang-format may produce different code formats, it is recommended to use version 14):
 
-`npm install clang-format@1.4.0`
+`npm install clang-format@1.6.0`
 
 Ubuntu: `apt-get install clang-format`
 
-The current version is 10.0, you can also specify the old version, for example: `apt-get install clang-format-9`
+The current version is 10.0, you can also specify the old version, for example: `apt-get install clang-format-9`. It is recommended to compile version 14.0 from source code.
 
 Mac: `brew install clang-format`
 
 Centos 7:
 
-The version of clang-format installed by centos yum is too old and supports too few StyleOptions. It is recommended to compile version 10.0 from source code.
+The version of clang-format installed by centos yum is too old and supports too few StyleOptions. It is recommended to compile version 14.0 from source code.
+
+LDB toolchain:
+
+If you are using [LDB toolchain](http://doris.incubator.apache.org/install/source-install/compilation-with-ldb-toolchain.html),
+the latest version (>= v0.11) of [LDB toolchain](https://github.com/amosbird/ldb_toolchain_gen/releases) has already included clang-format with 13.0.1 version.
 
 ### clang-format plugin
 
diff --git a/docs/zh-CN/developer-guide/cpp-format-code.md b/docs/zh-CN/developer-guide/cpp-format-code.md
index c265eb2bbc..522589a8d6 100644
--- a/docs/zh-CN/developer-guide/cpp-format-code.md
+++ b/docs/zh-CN/developer-guide/cpp-format-code.md
@@ -40,7 +40,7 @@ Doris使用clang-format进行代码格式化,并在build-support目录下提
 
 Doris的代码风格在Google Style的基础上稍有改动,定制为 `.clang-format` 文件,位于Doris根目录。
 
-目前,`.clang-format` 配置文件适配clang-format-8.0.1以上的版本。
+目前,`.clang-format` 配置文件适配clang-format-13.0.1以上的版本。
 
 `.clang-format-ignore` 文件中记录了不希望被格式化的代码。这些代码通常来自第三方代码库,建议保持原有代码风格。
 
@@ -50,19 +50,25 @@ Doris的代码风格在Google Style的基础上稍有改动,定制为 `.clang-
 
 ### 下载安装clang-format
 
-推荐使用 NPM 安装 clang-format 11(不同版本的 clang-format 可能产生不同的代码格式,建议使用 11 版本):
+推荐使用 NPM 安装 clang-format 14(不同版本的 clang-format 可能产生不同的代码格式,建议使用 14 版本):
 
-`npm install clang-format@1.4.0`
+`npm install clang-format@1.6.0`
 
 Ubuntu: `apt-get install clang-format` 
 
-当前版本为10.0,也可指定旧版本,例如: `apt-get install clang-format-9`
+当前版本为10.0,也可指定旧版本,例如: `apt-get install clang-format-9`,建议源码编译14.0版本。
 
 Mac: `brew install clang-format`
 
 Centos 7: 
 
-centos yum安装的clang-format版本过老,支持的StyleOption太少,建议源码编译10.0版本。
+centos yum安装的clang-format版本过老,支持的StyleOption太少,建议源码编译14.0版本。
+
+LDB toolchain:
+
+如果使用[LDB toolchain](http://doris.incubator.apache.org/zh-CN/install/source-install/compilation-with-ldb-toolchain.html),
+最新版本的[LDB toolchain](https://github.com/amosbird/ldb_toolchain_gen/releases)(>= v0.11)已经包含了预编译的clang-format
+13.0.1的二进制文件。
 
 ### clang-format插件
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org