From 75d3cb01a57071266a60cd9c4106dd74adda8cf0 Mon Sep 17 00:00:00 2001 From: David Steele Date: Mon, 7 Sep 2020 15:58:39 +0100 Subject: [PATCH] Adding clang format stylesheet Adding format script to check formatting before committing. Change-Id: I8dde01f25a9cc69d43be8e5ca17ca838eacf75c3 --- .clang-format | 96 +++++++++++++++++++++++++++++++++++++++ format | 1 + third-party/.clang-format | 5 ++ 3 files changed, 102 insertions(+) create mode 100644 .clang-format create mode 100755 format create mode 100644 third-party/.clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..d314ca158 --- /dev/null +++ b/.clang-format @@ -0,0 +1,96 @@ +--- +Language: Cpp +BasedOnStyle: Google +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignEscapedNewlinesLeft: true +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: true + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Allman +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +ConstructorInitializerAllOnOneLineOrOnePerLine: true +AllowAllConstructorInitializersOnNextLine : false +ConstructorInitializerIndentWidth: 0 +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +SpaceBeforeCtorInitializerColon: false +IndentCaseLabels: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '^DALI_ENUM_TO_STRING_TABLE_BEGIN' +MacroBlockEnd: 'DALI_ENUM_TO_STRING_TABLE_END' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: Never +SpaceInEmptyParentheses: false +SpacesInConditionalStatement : false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceAfterTemplateKeyword: false +Standard: Auto +TabWidth: 2 +UseTab: Never +... diff --git a/format b/format new file mode 100755 index 000000000..c5630b483 --- /dev/null +++ b/format @@ -0,0 +1 @@ +git diff -U0 --no-color HEAD^ | clang-format-diff -i -p1 \ No newline at end of file diff --git a/third-party/.clang-format b/third-party/.clang-format new file mode 100644 index 000000000..297ddc25a --- /dev/null +++ b/third-party/.clang-format @@ -0,0 +1,5 @@ +--- +Language: Cpp +DisableFormat: true +SortIncludes: false +... -- 2.34.1