[clang-format] update to clang-format-10 (#5616)

This commit is contained in:
Jonathan Hui 2020-10-07 21:17:44 -07:00 committed by GitHub
parent 061806620a
commit 58b0486bcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 46 deletions

View File

@ -20,7 +20,8 @@ AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: false
BraceWrapping:
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true

View File

@ -47,9 +47,7 @@ jobs:
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0
sudo apt-get autoremove
sudo apt-get --no-install-recommends install -y clang-tools clang-format-6.0 shellcheck
sudo apt-get --no-install-recommends install -y clang-format-10 shellcheck
python3 -m pip install yapf==0.29.0
sudo snap install shfmt
- name: Check

View File

@ -109,7 +109,7 @@ This will open up a text editor where you can specify which commits to squash.
#### Coding Conventions and Style
OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0) for C/C++ and [yapf v0.29.0](https://github.com/google/yapf) for Python.
OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v10.0.0](http://releases.llvm.org/download.html#10.0.0) for C/C++ and [yapf v0.29.0](https://github.com/google/yapf) for Python.
As part of the cleanup process, you should also run `script/make-pretty check` to ensure that your code passes the baseline code style checks.

View File

@ -116,7 +116,7 @@
- OpenThread uses `script/make-pretty` to reformat code and enforce code format and style. `script/make-pretty check` build target is included in OpenThread's continuous integration and must pass before a pull request is merged.
- `script/make-pretty` requires [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0) for C/C++ and [yapf v0.29.0](https://github.com/google/yapf) for Python.
- `script/make-pretty` requires [clang-format v10.0.0](http://releases.llvm.org/download.html#10.0.0) for C/C++ and [yapf v0.29.0](https://github.com/google/yapf) for Python.
### File Names

View File

@ -41,7 +41,7 @@
#include "MemManager.h"
otInstance * sInstance;
otInstance * sInstance;
OT_TOOL_WEAK uint32_t gInterruptDisableCount = 0;
void otSysInit(int argc, char *argv[])

View File

@ -59,7 +59,7 @@ install_packages_apt()
echo 'Installing pretty tools useful for code contributions...'
# add clang-format for pretty
sudo apt-get --no-install-recommends install -y clang-format-6.0
sudo apt-get --no-install-recommends install -y clang-format-10
# add yapf for pretty
python3 -m pip install yapf==0.29.0 || echo 'WARNING: could not install yapf, which is useful if you plan to contribute python code to the OpenThread project.'
@ -103,10 +103,10 @@ install_packages_brew()
echo 'Installing pretty tools useful for code contributions...'
# add clang-format for pretty
CLANG_FORMAT_VERSION="clang-format version 6.0"
command -v clang-format-6.0 || (command -v clang-format && (clang-format --version | grep -q "${CLANG_FORMAT_VERSION}")) || {
brew install llvm@6
sudo ln -s "$(brew --prefix llvm@6)/bin/clang-format" /usr/local/bin/clang-format-6.0
CLANG_FORMAT_VERSION="clang-format version 10"
command -v clang-format-10 || (command -v clang-format && (clang-format --version | grep -q "${CLANG_FORMAT_VERSION}")) || {
brew install llvm@10
sudo ln -s "$(brew --prefix llvm@6)/bin/clang-format" /usr/local/bin/clang-format-10
}
# add yapf for pretty

View File

@ -27,7 +27,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#
CLANG_FORMAT_VERSION="clang-format version 6.0"
CLANG_FORMAT_VERSION="clang-format version 10.0"
die()
{
@ -39,18 +39,18 @@ die()
# expand_aliases shell option is set using shopt.
shopt -s expand_aliases
if command -v clang-format-6.0 >/dev/null; then
alias clang-format=clang-format-6.0
if command -v clang-format-10 >/dev/null; then
alias clang-format=clang-format-10
elif command -v clang-format >/dev/null; then
case "$(clang-format --version)" in
"$CLANG_FORMAT_VERSION"*) ;;
*)
die "$(clang-format --version); clang-format 6.0 required"
die "$(clang-format --version); clang-format 10.0 required"
;;
esac
else
die "clang-format 6.0 required"
die "clang-format 10.0 required"
fi
clang-format "$@" || die

View File

@ -159,7 +159,7 @@ private:
void Advance(void);
void operator++(void) { Advance(); }
void operator++(int) { Advance(); }
const NdProxy &operator*(void)const { return *mCurrent; }
const NdProxy &operator*(void) const { return *mCurrent; }
bool operator==(const Iterator &aOther) const { return mCurrent == aOther.mCurrent; }
bool operator!=(const Iterator &aOther) const { return !(*this == aOther); }
NdProxy * operator->(void) { return mCurrent; }

View File

@ -916,7 +916,7 @@ public:
* @returns A reference to the `ChildInfo` entry currently pointed by the iterator.
*
*/
const ChildInfo &operator*(void)const { return mChildInfo; }
const ChildInfo &operator*(void) const { return mChildInfo; }
/**
* This method overloads operator `==` to evaluate whether or not two iterator instances are equal.

View File

@ -743,7 +743,7 @@ public:
* @returns A reference to the `Ip6::Address` entry currently pointed by the iterator.
*
*/
const Ip6::Address &operator*(void)const { return *GetAddress(); }
const Ip6::Address &operator*(void) const { return *GetAddress(); }
/**
* This method overloads operator `==` to evaluate whether or not two `Iterator` instances are equal.

View File

@ -864,12 +864,12 @@ otError RadioSpinel<InterfaceType, ProcessContextType>::ParseRadioFrame(otRadioF
unpacked = spinel_datatype_unpack_in_place(aBuffer, aLength,
SPINEL_DATATYPE_DATA_WLEN_S // Frame
SPINEL_DATATYPE_INT8_S // RSSI
SPINEL_DATATYPE_INT8_S // Noise Floor
SPINEL_DATATYPE_UINT16_S // Flags
SPINEL_DATATYPE_INT8_S // RSSI
SPINEL_DATATYPE_INT8_S // Noise Floor
SPINEL_DATATYPE_UINT16_S // Flags
SPINEL_DATATYPE_STRUCT_S( // PHY-data
SPINEL_DATATYPE_UINT8_S // 802.15.4 channel
SPINEL_DATATYPE_UINT8_S // 802.15.4 LQI
SPINEL_DATATYPE_UINT8_S // 802.15.4 LQI
SPINEL_DATATYPE_UINT64_S // Timestamp (us).
) SPINEL_DATATYPE_STRUCT_S( // Vendor-data
SPINEL_DATATYPE_UINT_PACKED_S // Receive error
@ -1203,22 +1203,22 @@ otError RadioSpinel<InterfaceType, ProcessContextType>::GetCoexMetrics(otRadioCo
error = Get(SPINEL_PROP_RADIO_COEX_METRICS,
SPINEL_DATATYPE_STRUCT_S( // Tx Coex Metrics Structure
SPINEL_DATATYPE_UINT32_S // NumTxRequest
SPINEL_DATATYPE_UINT32_S // NumTxGrantImmediate
SPINEL_DATATYPE_UINT32_S // NumTxGrantWait
SPINEL_DATATYPE_UINT32_S // NumTxGrantWaitActivated
SPINEL_DATATYPE_UINT32_S // NumTxGrantWaitTimeout
SPINEL_DATATYPE_UINT32_S // NumTxGrantDeactivatedDuringRequest
SPINEL_DATATYPE_UINT32_S // NumTxDelayedGrant
SPINEL_DATATYPE_UINT32_S // NumTxGrantImmediate
SPINEL_DATATYPE_UINT32_S // NumTxGrantWait
SPINEL_DATATYPE_UINT32_S // NumTxGrantWaitActivated
SPINEL_DATATYPE_UINT32_S // NumTxGrantWaitTimeout
SPINEL_DATATYPE_UINT32_S // NumTxGrantDeactivatedDuringRequest
SPINEL_DATATYPE_UINT32_S // NumTxDelayedGrant
SPINEL_DATATYPE_UINT32_S // AvgTxRequestToGrantTime
) SPINEL_DATATYPE_STRUCT_S( // Rx Coex Metrics Structure
SPINEL_DATATYPE_UINT32_S // NumRxRequest
SPINEL_DATATYPE_UINT32_S // NumRxGrantImmediate
SPINEL_DATATYPE_UINT32_S // NumRxGrantWait
SPINEL_DATATYPE_UINT32_S // NumRxGrantWaitActivated
SPINEL_DATATYPE_UINT32_S // NumRxGrantWaitTimeout
SPINEL_DATATYPE_UINT32_S // NumRxGrantDeactivatedDuringRequest
SPINEL_DATATYPE_UINT32_S // NumRxDelayedGrant
SPINEL_DATATYPE_UINT32_S // AvgRxRequestToGrantTime
SPINEL_DATATYPE_UINT32_S // NumRxGrantImmediate
SPINEL_DATATYPE_UINT32_S // NumRxGrantWait
SPINEL_DATATYPE_UINT32_S // NumRxGrantWaitActivated
SPINEL_DATATYPE_UINT32_S // NumRxGrantWaitTimeout
SPINEL_DATATYPE_UINT32_S // NumRxGrantDeactivatedDuringRequest
SPINEL_DATATYPE_UINT32_S // NumRxDelayedGrant
SPINEL_DATATYPE_UINT32_S // AvgRxRequestToGrantTime
SPINEL_DATATYPE_UINT32_S // NumRxGrantNone
) SPINEL_DATATYPE_BOOL_S // Stopped
SPINEL_DATATYPE_UINT32_S, // NumGrantGlitch
@ -1563,13 +1563,13 @@ otError RadioSpinel<InterfaceType, ProcessContextType>::Transmit(otRadioFrame &a
error = Request(true, SPINEL_CMD_PROP_VALUE_SET, SPINEL_PROP_STREAM_RAW,
SPINEL_DATATYPE_DATA_WLEN_S // Frame data
SPINEL_DATATYPE_UINT8_S // Channel
SPINEL_DATATYPE_UINT8_S // MaxCsmaBackoffs
SPINEL_DATATYPE_UINT8_S // MaxFrameRetries
SPINEL_DATATYPE_BOOL_S // CsmaCaEnabled
SPINEL_DATATYPE_BOOL_S // IsARetx
SPINEL_DATATYPE_BOOL_S // SkipAes
SPINEL_DATATYPE_UINT16_S // Period
SPINEL_DATATYPE_UINT8_S // Channel
SPINEL_DATATYPE_UINT8_S // MaxCsmaBackoffs
SPINEL_DATATYPE_UINT8_S // MaxFrameRetries
SPINEL_DATATYPE_BOOL_S // CsmaCaEnabled
SPINEL_DATATYPE_BOOL_S // IsARetx
SPINEL_DATATYPE_BOOL_S // SkipAes
SPINEL_DATATYPE_UINT16_S // Period
SPINEL_DATATYPE_UINT16_S, // Phase
mTransmitFrame->mPsdu, mTransmitFrame->mLength, mTransmitFrame->mChannel,
mTransmitFrame->mInfo.mTxInfo.mMaxCsmaBackoffs, mTransmitFrame->mInfo.mTxInfo.mMaxFrameRetries,

View File

@ -112,7 +112,7 @@ void TestDecoder(void)
SPINEL_DATATYPE_UINT_PACKED_S SPINEL_DATATYPE_UINT_PACKED_S SPINEL_DATATYPE_UINT_PACKED_S
SPINEL_DATATYPE_IPv6ADDR_S SPINEL_DATATYPE_EUI48_S SPINEL_DATATYPE_EUI64_S
SPINEL_DATATYPE_UTF8_S SPINEL_DATATYPE_UTF8_S SPINEL_DATATYPE_DATA_WLEN_S
SPINEL_DATATYPE_DATA_S),
SPINEL_DATATYPE_DATA_S),
kBool_1, kBool_2, kUint8, kInt8, kUint16, kInt16, kUint32, kInt32, kUint64, kInt64, kUint_1, kUint_2, kUint_3,
kUint_4, &kIp6Addr, &kEui48, &kEui64, kString_1, kString_2, kData, sizeof(kData), kData, sizeof(kData));
@ -605,7 +605,7 @@ void TestDecoder(void)
frameLen = spinel_datatype_pack(buffer, sizeof(buffer),
(SPINEL_DATATYPE_UINT8_S SPINEL_DATATYPE_UINT16_S // Treat this as struct length
SPINEL_DATATYPE_BOOL_S),
SPINEL_DATATYPE_BOOL_S),
kUint8, 10, kBool_1);
DumpBuffer("Packed Spinel Frame (incorrect format)", buffer, static_cast<uint16_t>(frameLen));