Skip to content

Commit 685c527

Browse files
authored
Fixed clang configuration file (#360)
* Fixed clang configuration file + reformatted code. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Applying changes related to clang-format 16 Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Clang format now works without String quotation. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Adding ability to have includes in groups. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Change requested by Michal P. and NXP company -- includes will not be sorted at all (not even in groups) -- Constructutor and inheritance will use AfterColon format style Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Update clang-format.yml Update clang-format version Signed-off-by: Cervenka Dusan <cervenka@acrios.com> --------- Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
1 parent 958569b commit 685c527

File tree

105 files changed

+796
-1082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+796
-1082
lines changed

.clang-format

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
#https://releases.llvm.org/5.0.2/tools/clang/docs/ClangFormatStyleOptions.html
2-
AlignTrailingComments: true
1+
#https://releases.llvm.org/16.0.0/tools/clang/docs/ClangFormatStyleOptions.html
2+
AlignTrailingComments:
3+
Kind: Always
4+
OverEmptyLines: 0
35
AllowAllParametersOfDeclarationOnNextLine: true
4-
AllowShortBlocksOnASingleLine: false
5-
AllowShortFunctionsOnASingleLine: "Inline"
6-
AllowShortIfStatementsOnASingleLine: false
6+
AllowShortBlocksOnASingleLine: Never
7+
AllowShortFunctionsOnASingleLine: Inline
8+
AllowShortIfStatementsOnASingleLine: Never
79
AllowShortLoopsOnASingleLine: false
810
AlwaysBreakBeforeMultilineStrings: true
9-
BasedOnStyle: "Google"
11+
BasedOnStyle: Google
1012
#BinPackParameters : false
11-
BreakBeforeBinaryOperators: false
12-
BreakBeforeBraces: "Custom"
13+
BreakBeforeBinaryOperators: None
14+
BreakBeforeBraces: Custom
1315
BreakBeforeTernaryOperators: false
1416
ColumnLimit: 120
1517
ContinuationIndentWidth: 4
@@ -18,54 +20,61 @@ DisableFormat: false
1820
IndentCaseLabels: true
1921
IndentWrappedFunctionNames: false
2022
IndentWidth: 4
21-
Language: "Cpp"
23+
Language: Cpp
2224
MaxEmptyLinesToKeep: 1
23-
PointerBindsToType: false
2425
SpaceBeforeAssignmentOperators: true
25-
SpaceBeforeParens: "ControlStatements"
26+
SpaceBeforeParens: ControlStatements
2627
SpacesBeforeTrailingComments: 1
2728
SpacesInCStyleCastParentheses: false
2829
SpacesInParentheses: false
29-
Standard: "Cpp03"
30+
Standard: c++11
3031
TabWidth: 1
31-
UseTab: "Never"
32+
UseTab: Never
3233
AccessModifierOffset: -4
33-
AlignAfterOpenBracket: "Align"
34-
AlignEscapedNewlines: "Left"
35-
AlignOperands: true
34+
AlignAfterOpenBracket: Align
35+
AlignEscapedNewlines: Left
36+
AlignOperands: Align
3637
AllowShortCaseLabelsOnASingleLine: false
37-
AlwaysBreakAfterReturnType: "None"
38-
AlwaysBreakTemplateDeclarations: true
39-
BreakBeforeInheritanceComma: false
40-
BreakConstructorInitializers: "BeforeComma"
38+
AlwaysBreakAfterReturnType: None
39+
AlwaysBreakTemplateDeclarations: Yes
40+
BreakInheritanceList: AfterColon
41+
BreakConstructorInitializers: AfterColon
4142
CompactNamespaces: false
4243
ConstructorInitializerAllOnOneLineOrOnePerLine: false
4344
ConstructorInitializerIndentWidth: 0
4445
Cpp11BracedListStyle: false
4546
FixNamespaceComments: true
46-
NamespaceIndentation: "None"
47-
PointerAlignment: "Right"
48-
SortIncludes: true
49-
SortUsingDeclarations: true
50-
SpacesInAngles: false
47+
NamespaceIndentation: None
48+
PointerAlignment: Right
49+
SortIncludes: Never
50+
SortUsingDeclarations: Lexicographic
51+
SpacesInAngles: Never
5152
SpaceAfterCStyleCast: false
5253
SpaceInEmptyParentheses: false
5354
SpacesInSquareBrackets: false
5455
KeepEmptyLinesAtTheStartOfBlocks: true
5556
BraceWrapping:
57+
AfterCaseLabel: true
5658
AfterClass: true
57-
AfterControlStatement: true
59+
AfterControlStatement: Always
5860
AfterEnum: true
5961
AfterFunction: true
6062
AfterNamespace: false
6163
AfterObjCDeclaration: true
6264
AfterStruct: true
6365
AfterUnion: true
66+
AfterExternBlock: false
6467
BeforeCatch: true
6568
BeforeElse: true
66-
IncludeBlocks: "Preserve" # for future version of clang
69+
BeforeWhile: false
70+
SplitEmptyFunction: true
71+
SplitEmptyRecord: true
72+
SplitEmptyNamespace: true
73+
74+
IncludeBlocks: Preserve
6775
IncludeCategories:
6876
- Regex: "^<" # system includes
6977
Priority: 10
7078
- Regex: '^"erpc_' # erpc public includes
7179
Priority: 1
80+
CommentPragmas: "#"

.clang-format-ignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#list of ignored files to format
2+
./erpc_c/port/erpc_serial.cpp
3+
./erpcgen/src/cpptemplate/cpptempl.hpp
4+
./erpcgen/src/cpptemplate/cpptempl.cpp
5+
./erpcgen/src/cpptemplate/cpptempl_test.cpp
6+
./erpcgen/test/test_includes/test_includes_union.h
7+
./test/common/gtest/gtest.h
8+
./test/common/gtest/gtest.cpp
9+
./test/common/retarget_cpp_streamed_io.c

.github/workflows/clang-format.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
name: clang-format lint
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: DoozyX/clang-format-lint-action@v0.10
10+
- uses: actions/checkout@v4
11+
- uses: DoozyX/clang-format-lint-action@v0.16.2
1212
with:
13-
source: '.'
14-
exclude: 'test/common/gtest/gtest.h test/common/gtest/gtest.cpp erpcgen/src/cpptemplate/cpptempl.h erpcgen/src/cpptemplate/cpptempl.cpp erpcgen/src/cpptemplate/cpptempl_test.cpp'
15-
clangFormatVersion: 10
13+
source: '.'
14+
clangFormatVersion: 16

erpc_c/infra/erpc_arbitrated_client_manager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include "erpc_arbitrated_client_manager.hpp"
12+
1213
#include "erpc_transport_arbitrator.hpp"
1314

1415
#if ERPC_THREADS_IS(NONE)

erpc_c/infra/erpc_arbitrated_client_manager.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ class ArbitratedClientManager : public ClientManager
4545
*
4646
* This function initializes object attributes.
4747
*/
48-
ArbitratedClientManager(void)
49-
: ClientManager()
50-
, m_arbitrator(NULL)
51-
{
52-
}
48+
ArbitratedClientManager(void) : ClientManager(), m_arbitrator(NULL) {}
5349

5450
/*!
5551
* @brief Sets the transport arbitrator instance.
@@ -63,7 +59,7 @@ class ArbitratedClientManager : public ClientManager
6359
*
6460
* @return TransportArbitrator * Transport arbitrator instance.
6561
*/
66-
TransportArbitrator * getArbitrator(void) { return m_arbitrator; };
62+
TransportArbitrator *getArbitrator(void) { return m_arbitrator; };
6763

6864
protected:
6965
TransportArbitrator *m_arbitrator; //!< Optional transport arbitrator. May be NULL.

erpc_c/infra/erpc_basic_codec.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ using namespace erpc;
2727

2828
const uint32_t BasicCodec::kBasicCodecVersion = 1UL;
2929

30-
BasicCodec::BasicCodec(void)
31-
: Codec()
32-
{
33-
}
30+
BasicCodec::BasicCodec(void) : Codec() {}
3431

3532
BasicCodec::~BasicCodec(void) {}
3633

@@ -374,10 +371,7 @@ void BasicCodec::readNullFlag(bool &isNull)
374371

375372
ERPC_MANUALLY_CONSTRUCTED_ARRAY_STATIC(BasicCodec, s_basicCodecManual, ERPC_CODEC_COUNT);
376373

377-
BasicCodecFactory::BasicCodecFactory(void)
378-
: CodecFactory()
379-
{
380-
}
374+
BasicCodecFactory::BasicCodecFactory(void) : CodecFactory() {}
381375

382376
BasicCodecFactory::~BasicCodecFactory(void) {}
383377

erpc_c/infra/erpc_client_manager.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ class ClientManager : public ClientServerCommon
6161
*
6262
* This function initializes object attributes.
6363
*/
64-
ClientManager(void)
65-
: ClientServerCommon()
66-
, m_sequence(0)
67-
, m_errorHandler(NULL)
64+
ClientManager(void) :
65+
ClientServerCommon(), m_sequence(0), m_errorHandler(NULL)
6866
#if ERPC_NESTED_CALLS
69-
, m_server(NULL)
70-
, m_serverThreadId(NULL)
67+
,
68+
m_server(NULL), m_serverThreadId(NULL)
7169
#endif
7270
{
7371
}
@@ -195,10 +193,8 @@ class RequestContext
195193
* @param[in] codec Set in inout codec.
196194
* @param[in] isOneway Set information if codec is only oneway or bidirectional.
197195
*/
198-
RequestContext(uint32_t sequence, Codec *codec, bool argIsOneway)
199-
: m_sequence(sequence)
200-
, m_codec(codec)
201-
, m_oneway(argIsOneway)
196+
RequestContext(uint32_t sequence, Codec *codec, bool argIsOneway) :
197+
m_sequence(sequence), m_codec(codec), m_oneway(argIsOneway)
202198
{
203199
}
204200

erpc_c/infra/erpc_client_server_common.hpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ClientServerCommon
6666
#endif
6767
#if ERPC_MESSAGE_LOGGING
6868
#ifdef ERPC_OTHER_INHERITANCE
69-
,
69+
,
7070
#else
7171
#define ERPC_OTHER_INHERITANCE 1
7272
:
@@ -75,23 +75,20 @@ class ClientServerCommon
7575
#endif
7676
#if ERPC_PRE_POST_ACTION
7777
#ifdef ERPC_OTHER_INHERITANCE
78-
,
78+
,
7979
#else
8080
#define ERPC_OTHER_INHERITANCE 1
8181
:
8282
#endif
8383
PrePostAction()
8484
#endif
8585
#ifdef ERPC_OTHER_INHERITANCE
86-
,
86+
,
8787
#else
8888
#define ERPC_OTHER_INHERITANCE 1
8989
:
9090
#endif
91-
m_messageFactory(NULL)
92-
, m_codecFactory(NULL)
93-
, m_transport(NULL)
94-
{};
91+
m_messageFactory(NULL), m_codecFactory(NULL), m_transport(NULL){};
9592

9693
/*!
9794
* @brief ClientServerCommon destructor
@@ -103,21 +100,21 @@ class ClientServerCommon
103100
*
104101
* @param[in] factory Message buffer factory to use.
105102
*/
106-
void setMessageBufferFactory(MessageBufferFactory *factory) { m_messageFactory = factory; }
103+
void setMessageBufferFactory(MessageBufferFactory * factory) { m_messageFactory = factory; }
107104

108105
/*!
109106
* @brief This function sets codec factory to use.
110107
*
111108
* @param[in] factory Codec factory to use.
112109
*/
113-
void setCodecFactory(CodecFactory *factory) { m_codecFactory = factory; }
110+
void setCodecFactory(CodecFactory * factory) { m_codecFactory = factory; }
114111

115112
/*!
116113
* @brief This function sets codec factory to use.
117114
*
118115
* @return CodecFactory * Codec factory to use.
119116
*/
120-
CodecFactory * getCodecFactory(void) { return m_codecFactory; }
117+
CodecFactory *getCodecFactory(void) { return m_codecFactory; }
121118

122119
/*!
123120
* @brief This function sets transport layer to use.
@@ -126,14 +123,14 @@ class ClientServerCommon
126123
*
127124
* @param[in] transport Transport layer to use.
128125
*/
129-
void setTransport(Transport *transport) { m_transport = transport; }
126+
void setTransport(Transport * transport) { m_transport = transport; }
130127

131128
/*!
132129
* @brief This function gets transport instance.
133130
*
134131
* @return Transport * Pointer to transport instance.
135132
*/
136-
Transport * getTransport(void) { return m_transport; }
133+
Transport *getTransport(void) { return m_transport; }
137134

138135
protected:
139136
MessageBufferFactory *m_messageFactory; //!< Message buffer factory to use.

erpc_c/infra/erpc_codec.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ class Codec
5858
*
5959
* This function initializes object attributes.
6060
*/
61-
Codec(void)
62-
: m_cursor()
63-
, m_status(kErpcStatus_Success)
64-
{
65-
}
61+
Codec(void) : m_cursor(), m_status(kErpcStatus_Success) {}
6662

6763
/*!
6864
* @brief Codec destructor

erpc_c/infra/erpc_crc16.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ using namespace erpc;
1515
// Code
1616
////////////////////////////////////////////////////////////////////////////////
1717

18-
Crc16::Crc16(uint32_t crcStart)
19-
: m_crcStart(crcStart)
20-
{
21-
}
18+
Crc16::Crc16(uint32_t crcStart) : m_crcStart(crcStart) {}
2219

23-
Crc16::Crc16(void)
24-
: m_crcStart(0xEF4A)
25-
{
26-
}
20+
Crc16::Crc16(void) : m_crcStart(0xEF4A) {}
2721

2822
Crc16::~Crc16(void) {}
2923

0 commit comments

Comments
 (0)