Skip to content

Commit

Permalink
Add .clang-format
Browse files Browse the repository at this point in the history
After a bunch of testing, this Clang Format configuration is quite close
to what is done _most of the time_ in this repository. The only thing
I've found which it breaks consistently is when an UDT is instanciated
inline, the braces are split:
```
struct bar
{} foo;
```
becomes
```
struct bar
{
} foo;
```
and (maybe worse cause that's how it's often written in this project)
```
struct bar
{}
// comment
foo;
```
becomes
```
struct bar
{
}
// comment
foo;
```
. This along with disallowing the rest of multiple operator seperated
items in argument position to flow to the last line if they are
neccesary to split giving:
```
throw invalid_argument("Adiar requires at least "
                       + std::to_string(minimum_memory / 1024 / 1024) + " MiB of memory");
```
instead of
```
throw invalid_argument("Adiar requires at least "
                       + std::to_string(minimum_memory / 1024 / 1024)
		       + " MiB of memory");
```

Except for that, all changes I've observed it making is within
"normal" for the codebase.
  • Loading branch information
halvko committed Dec 14, 2023
1 parent 494e3dd commit cbe623f
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
BasedOnStyle: LLVM
Language: Cpp

AlignAfterOpenBracket: Align
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: true
PadOperators: true
AlignOperands: AlignAfterOperator
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: All
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: true
Cpp11BracedListStyle: true
FixNamespaceComments: false
IndentWidth: 2
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PointerAlignment: Left
SpaceAfterTemplateKeyword: false
# type above function name
# short if on same line

0 comments on commit cbe623f

Please sign in to comment.