Skip to content

Commit

Permalink
Fixed clang configuration file (EmbeddedRPC#360)
Browse files Browse the repository at this point in the history
* Fixed clang configuration file

+ reformatted code.

Signed-off-by: Cervenka Dusan <[email protected]>

* Applying changes related to clang-format 16

Signed-off-by: Cervenka Dusan <[email protected]>

* Clang format now works without String quotation.

Signed-off-by: Cervenka Dusan <[email protected]>

* Adding ability to have includes in groups.

Signed-off-by: Cervenka Dusan <[email protected]>

* 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 <[email protected]>

* Update clang-format.yml

Update clang-format version

Signed-off-by: Cervenka Dusan <[email protected]>

---------

Signed-off-by: Cervenka Dusan <[email protected]>
  • Loading branch information
Hadatko committed Nov 2, 2023
1 parent 958569b commit 685c527
Show file tree
Hide file tree
Showing 105 changed files with 796 additions and 1,082 deletions.
63 changes: 36 additions & 27 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#https://releases.llvm.org/5.0.2/tools/clang/docs/ClangFormatStyleOptions.html
AlignTrailingComments: true
#https://releases.llvm.org/16.0.0/tools/clang/docs/ClangFormatStyleOptions.html
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: "Inline"
AllowShortIfStatementsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: true
BasedOnStyle: "Google"
BasedOnStyle: Google
#BinPackParameters : false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: "Custom"
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
ColumnLimit: 120
ContinuationIndentWidth: 4
Expand All @@ -18,54 +20,61 @@ DisableFormat: false
IndentCaseLabels: true
IndentWrappedFunctionNames: false
IndentWidth: 4
Language: "Cpp"
Language: Cpp
MaxEmptyLinesToKeep: 1
PointerBindsToType: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: "ControlStatements"
SpaceBeforeParens: ControlStatements
SpacesBeforeTrailingComments: 1
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
Standard: "Cpp03"
Standard: c++11
TabWidth: 1
UseTab: "Never"
UseTab: Never
AccessModifierOffset: -4
AlignAfterOpenBracket: "Align"
AlignEscapedNewlines: "Left"
AlignOperands: true
AlignAfterOpenBracket: Align
AlignEscapedNewlines: Left
AlignOperands: Align
AllowShortCaseLabelsOnASingleLine: false
AlwaysBreakAfterReturnType: "None"
AlwaysBreakTemplateDeclarations: true
BreakBeforeInheritanceComma: false
BreakConstructorInitializers: "BeforeComma"
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakInheritanceList: AfterColon
BreakConstructorInitializers: AfterColon
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
Cpp11BracedListStyle: false
FixNamespaceComments: true
NamespaceIndentation: "None"
PointerAlignment: "Right"
SortIncludes: true
SortUsingDeclarations: true
SpacesInAngles: false
NamespaceIndentation: None
PointerAlignment: Right
SortIncludes: Never
SortUsingDeclarations: Lexicographic
SpacesInAngles: Never
SpaceAfterCStyleCast: false
SpaceInEmptyParentheses: false
SpacesInSquareBrackets: false
KeepEmptyLinesAtTheStartOfBlocks: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IncludeBlocks: "Preserve" # for future version of clang
BeforeWhile: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

IncludeBlocks: Preserve
IncludeCategories:
- Regex: "^<" # system includes
Priority: 10
- Regex: '^"erpc_' # erpc public includes
Priority: 1
CommentPragmas: "#"
9 changes: 9 additions & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#list of ignored files to format
./erpc_c/port/erpc_serial.cpp
./erpcgen/src/cpptemplate/cpptempl.hpp
./erpcgen/src/cpptemplate/cpptempl.cpp
./erpcgen/src/cpptemplate/cpptempl_test.cpp
./erpcgen/test/test_includes/test_includes_union.h
./test/common/gtest/gtest.h
./test/common/gtest/gtest.cpp
./test/common/retarget_cpp_streamed_io.c
11 changes: 5 additions & 6 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: clang-format lint

on: [push]
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.10
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.16.2
with:
source: '.'
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'
clangFormatVersion: 10
source: '.'
clangFormatVersion: 16
1 change: 1 addition & 0 deletions erpc_c/infra/erpc_arbitrated_client_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#include "erpc_arbitrated_client_manager.hpp"

#include "erpc_transport_arbitrator.hpp"

#if ERPC_THREADS_IS(NONE)
Expand Down
8 changes: 2 additions & 6 deletions erpc_c/infra/erpc_arbitrated_client_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ class ArbitratedClientManager : public ClientManager
*
* This function initializes object attributes.
*/
ArbitratedClientManager(void)
: ClientManager()
, m_arbitrator(NULL)
{
}
ArbitratedClientManager(void) : ClientManager(), m_arbitrator(NULL) {}

/*!
* @brief Sets the transport arbitrator instance.
Expand All @@ -63,7 +59,7 @@ class ArbitratedClientManager : public ClientManager
*
* @return TransportArbitrator * Transport arbitrator instance.
*/
TransportArbitrator * getArbitrator(void) { return m_arbitrator; };
TransportArbitrator *getArbitrator(void) { return m_arbitrator; };

protected:
TransportArbitrator *m_arbitrator; //!< Optional transport arbitrator. May be NULL.
Expand Down
10 changes: 2 additions & 8 deletions erpc_c/infra/erpc_basic_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ using namespace erpc;

const uint32_t BasicCodec::kBasicCodecVersion = 1UL;

BasicCodec::BasicCodec(void)
: Codec()
{
}
BasicCodec::BasicCodec(void) : Codec() {}

BasicCodec::~BasicCodec(void) {}

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

ERPC_MANUALLY_CONSTRUCTED_ARRAY_STATIC(BasicCodec, s_basicCodecManual, ERPC_CODEC_COUNT);

BasicCodecFactory::BasicCodecFactory(void)
: CodecFactory()
{
}
BasicCodecFactory::BasicCodecFactory(void) : CodecFactory() {}

BasicCodecFactory::~BasicCodecFactory(void) {}

Expand Down
16 changes: 6 additions & 10 deletions erpc_c/infra/erpc_client_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ class ClientManager : public ClientServerCommon
*
* This function initializes object attributes.
*/
ClientManager(void)
: ClientServerCommon()
, m_sequence(0)
, m_errorHandler(NULL)
ClientManager(void) :
ClientServerCommon(), m_sequence(0), m_errorHandler(NULL)
#if ERPC_NESTED_CALLS
, m_server(NULL)
, m_serverThreadId(NULL)
,
m_server(NULL), m_serverThreadId(NULL)
#endif
{
}
Expand Down Expand Up @@ -195,10 +193,8 @@ class RequestContext
* @param[in] codec Set in inout codec.
* @param[in] isOneway Set information if codec is only oneway or bidirectional.
*/
RequestContext(uint32_t sequence, Codec *codec, bool argIsOneway)
: m_sequence(sequence)
, m_codec(codec)
, m_oneway(argIsOneway)
RequestContext(uint32_t sequence, Codec *codec, bool argIsOneway) :
m_sequence(sequence), m_codec(codec), m_oneway(argIsOneway)
{
}

Expand Down
21 changes: 9 additions & 12 deletions erpc_c/infra/erpc_client_server_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ClientServerCommon
#endif
#if ERPC_MESSAGE_LOGGING
#ifdef ERPC_OTHER_INHERITANCE
,
,
#else
#define ERPC_OTHER_INHERITANCE 1
:
Expand All @@ -75,23 +75,20 @@ class ClientServerCommon
#endif
#if ERPC_PRE_POST_ACTION
#ifdef ERPC_OTHER_INHERITANCE
,
,
#else
#define ERPC_OTHER_INHERITANCE 1
:
#endif
PrePostAction()
#endif
#ifdef ERPC_OTHER_INHERITANCE
,
,
#else
#define ERPC_OTHER_INHERITANCE 1
:
#endif
m_messageFactory(NULL)
, m_codecFactory(NULL)
, m_transport(NULL)
{};
m_messageFactory(NULL), m_codecFactory(NULL), m_transport(NULL){};

/*!
* @brief ClientServerCommon destructor
Expand All @@ -103,21 +100,21 @@ class ClientServerCommon
*
* @param[in] factory Message buffer factory to use.
*/
void setMessageBufferFactory(MessageBufferFactory *factory) { m_messageFactory = factory; }
void setMessageBufferFactory(MessageBufferFactory * factory) { m_messageFactory = factory; }

/*!
* @brief This function sets codec factory to use.
*
* @param[in] factory Codec factory to use.
*/
void setCodecFactory(CodecFactory *factory) { m_codecFactory = factory; }
void setCodecFactory(CodecFactory * factory) { m_codecFactory = factory; }

/*!
* @brief This function sets codec factory to use.
*
* @return CodecFactory * Codec factory to use.
*/
CodecFactory * getCodecFactory(void) { return m_codecFactory; }
CodecFactory *getCodecFactory(void) { return m_codecFactory; }

/*!
* @brief This function sets transport layer to use.
Expand All @@ -126,14 +123,14 @@ class ClientServerCommon
*
* @param[in] transport Transport layer to use.
*/
void setTransport(Transport *transport) { m_transport = transport; }
void setTransport(Transport * transport) { m_transport = transport; }

/*!
* @brief This function gets transport instance.
*
* @return Transport * Pointer to transport instance.
*/
Transport * getTransport(void) { return m_transport; }
Transport *getTransport(void) { return m_transport; }

protected:
MessageBufferFactory *m_messageFactory; //!< Message buffer factory to use.
Expand Down
6 changes: 1 addition & 5 deletions erpc_c/infra/erpc_codec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ class Codec
*
* This function initializes object attributes.
*/
Codec(void)
: m_cursor()
, m_status(kErpcStatus_Success)
{
}
Codec(void) : m_cursor(), m_status(kErpcStatus_Success) {}

/*!
* @brief Codec destructor
Expand Down
10 changes: 2 additions & 8 deletions erpc_c/infra/erpc_crc16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@ using namespace erpc;
// Code
////////////////////////////////////////////////////////////////////////////////

Crc16::Crc16(uint32_t crcStart)
: m_crcStart(crcStart)
{
}
Crc16::Crc16(uint32_t crcStart) : m_crcStart(crcStart) {}

Crc16::Crc16(void)
: m_crcStart(0xEF4A)
{
}
Crc16::Crc16(void) : m_crcStart(0xEF4A) {}

Crc16::~Crc16(void) {}

Expand Down
9 changes: 4 additions & 5 deletions erpc_c/infra/erpc_framed_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ using namespace erpc;
// Code
////////////////////////////////////////////////////////////////////////////////

FramedTransport::FramedTransport(void)
: Transport()
, m_crcImpl(NULL)
FramedTransport::FramedTransport(void) :
Transport(), m_crcImpl(NULL)
#if !ERPC_THREADS_IS(NONE)
, m_sendLock()
, m_receiveLock()
,
m_sendLock(), m_receiveLock()
#endif
{
}
Expand Down
Loading

0 comments on commit 685c527

Please sign in to comment.