From 2a6add0ca1569e67f8ce62bdebc2e300eb2287cc Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Wed, 26 Dec 2018 01:15:34 +0100 Subject: [PATCH] added new clang style and reformat script for clang-format 6.0 --- .clang-format | 109 +++++++++++++++++++++++++++++++- lib/Basics/Common.h | 6 ++ lib/Basics/VelocyPackDumper.cpp | 4 +- utils/reformat.sh | 7 ++ 4 files changed, 123 insertions(+), 3 deletions(-) create mode 100755 utils/reformat.sh diff --git a/.clang-format b/.clang-format index 387684359d..5795138862 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,109 @@ -BasedOnStyle: Google +--- +Language: Cpp +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^' + Priority: 2 + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 100 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1 +PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Left -Standard: Cpp11 +BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +... + diff --git a/lib/Basics/Common.h b/lib/Basics/Common.h index 95c70a5b87..b2ddf410d9 100644 --- a/lib/Basics/Common.h +++ b/lib/Basics/Common.h @@ -32,8 +32,10 @@ // debug malloc for Windows (only used when DEBUG is set) #define _CRTDBG_MAP_ALLOC +// clang-format off #include #include +// clang-format on #ifndef NOMINMAX #define NOMINMAX @@ -42,8 +44,10 @@ #endif #define TRI_WITHIN_COMMON 1 +// clang-format off #include "Basics/operating-system.h" #include "Basics/application-exit.h" +// clang-format on #undef TRI_WITHIN_COMMON #include @@ -168,6 +172,7 @@ typedef long suseconds_t; #include #define TRI_WITHIN_COMMON 1 +// clang-format off #include "Basics/voc-errors.h" #include "Basics/error.h" #include "Basics/debugging.h" @@ -175,6 +180,7 @@ typedef long suseconds_t; #include "Basics/memory.h" #include "Basics/system-compiler.h" #include "Basics/system-functions.h" +// clang-format on #undef TRI_WITHIN_COMMON #ifdef _WIN32 diff --git a/lib/Basics/VelocyPackDumper.cpp b/lib/Basics/VelocyPackDumper.cpp index d3c3c85162..697a599bfc 100644 --- a/lib/Basics/VelocyPackDumper.cpp +++ b/lib/Basics/VelocyPackDumper.cpp @@ -27,10 +27,12 @@ #include "Logger/Logger.h" #include + #include -#include "velocypack/Iterator.h" +#include #include #include + #include using namespace arangodb::basics; diff --git a/utils/reformat.sh b/utils/reformat.sh new file mode 100755 index 0000000000..66962b8883 --- /dev/null +++ b/utils/reformat.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +find arangod arangosh lib enterprise \ + -name Zip -prune -o \ + -type f "(" -name "*.cpp" -o -name "*.h" ")" \ + "!" "(" -name "tokens.*" -o -name "v8-json.*" -o -name "voc-errors.*" -o -name "grammar.*" -o -name "xxhash.*" -o -name "exitcodes.*" ")" | \ + xargs clang-format -i -verbose