Skip to content

Commit 9f18b7f

Browse files
committed
Update clang-format
1 parent c755a88 commit 9f18b7f

File tree

89 files changed

+10737
-10906
lines changed

Some content is hidden

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

89 files changed

+10737
-10906
lines changed

.clang-format

+34-12
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ AccessModifierOffset: -4
22
AlignAfterOpenBracket: Align
33
AlignConsecutiveAssignments: true
44
AlignConsecutiveDeclarations: true
5-
AlignEscapedNewlinesLeft: false
5+
AlignEscapedNewlinesLeft: Right
66
AlignOperands: true
77
AlignTrailingComments: true
8-
AllowAllParametersOfDeclarationOnNextLine: true
8+
AllowAllParametersOfDeclarationOnNextLine: false
99
AllowShortBlocksOnASingleLine: false
1010
AllowShortCaseLabelsOnASingleLine: false
1111
AllowShortFunctionsOnASingleLine: Empty
@@ -16,28 +16,50 @@ AlwaysBreakBeforeMultilineStrings: false
1616
AlwaysBreakTemplateDeclarations: true
1717
BinPackArguments: true
1818
BinPackParameters: true
19-
BreakBeforeBinaryOperators: NonAssignment
20-
BreakBeforeBraces: Allman
21-
BreakBeforeTernaryOperators: false
22-
BreakConstructorInitializersBeforeComma: false
23-
ConstructorInitializerAllOnOneLineOrOnePerLine: true
19+
BreakBeforeBraces: Custom
20+
BraceWrapping:
21+
AfterClass: true
22+
AfterControlStatement: true
23+
AfterEnum: true
24+
AfterFunction: true
25+
AfterNamespace: true
26+
AfterStruct: true
27+
AfterUnion: true
28+
AfterExternBlock: true
29+
BeforeCatch: true
30+
BeforeElse: true
31+
SplitEmptyFunction: false
32+
SplitEmptyRecord: false
33+
SplitEmptyNamespace: false
34+
BreakBeforeBinaryOperators: All
35+
BreakBeforeTernaryOperators: true
36+
BreakConstructorInitializers: BeforeColon
37+
BreakStringLiterals: false
38+
ColumnLimit: 100
39+
CompactNamespaces: true
40+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
2441
ConstructorInitializerIndentWidth: 0
2542
ContinuationIndentWidth: 4
26-
ColumnLimit: 100
2743
Cpp11BracedListStyle: true
44+
DerivePointerAlignment: false
45+
FixNamespaceComments: true
46+
IncludeBlocks: Preserve
2847
IndentCaseLabels: false
48+
IndentPPDirectives: AfterHash
2949
IndentWidth: 4
3050
IndentWrappedFunctionNames: true
31-
Language: Cpp
3251
KeepEmptyLinesAtTheStartOfBlocks: false
52+
Language: Cpp
3353
MaxEmptyLinesToKeep: 1
34-
NamespaceIndentation: All
54+
NamespaceIndentation: Inner
3555
PenaltyBreakBeforeFirstCallParameter: 19937
3656
PenaltyReturnTypeOnItsOwnLine: 19937
3757
PointerAlignment: Left
38-
ReflowComments: false
39-
SortIncludes: false
58+
ReflowComments: true
59+
SortIncludes: true
60+
SortUsingDeclarations: true
4061
SpaceAfterCStyleCast: false
62+
SpaceAfterTemplateKeyword: true
4163
SpaceBeforeAssignmentOperators: true
4264
SpaceBeforeParens: ControlStatements
4365
SpaceInEmptyParentheses: false

example/comparison.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/// \file
66
/// Generate equality comparisons.
77
///
8-
/// Given an input file, it will generate comparison operators for each class that has the [[generate::comparison]] attribute.
8+
/// Given an input file, it will generate comparison operators for each class that has the
9+
/// [[generate::comparison]] attribute.
910

1011
#include <algorithm>
1112
#include <iostream>
@@ -94,8 +95,8 @@ void generate_comparison(const cppast::cpp_file& file)
9495
{
9596
// it is a new class
9697
auto& class_ = static_cast<const cppast::cpp_class&>(e);
97-
auto& attribute =
98-
cppast::has_attribute(e, "generate::comparison").value();
98+
auto& attribute
99+
= cppast::has_attribute(e, "generate::comparison").value();
99100

100101
// generate requested operators
101102
if (attribute.arguments())

example/enum_category.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
/// \file
66
/// Generates enum category functions.
77
///
8-
/// Given an input file, it will generate definitions for functions marked with [[generate::enum_category(name)]].
9-
/// The function takes an enumerator and will return true if it is marked with the same category.
8+
/// Given an input file, it will generate definitions for functions marked with
9+
/// [[generate::enum_category(name)]]. The function takes an enumerator and will return true if it
10+
/// is marked with the same category.
1011

1112
#include <algorithm>
1213
#include <cassert>
@@ -24,10 +25,10 @@ bool is_category(const cppast::cpp_enum_value& e, const std::string& name)
2425
if (auto attr = cppast::has_attribute(e, "generate::enum_category"))
2526
{
2627
// ... by looking for the token
27-
auto iter =
28-
std::find_if(attr.value().arguments().value().begin(),
29-
attr.value().arguments().value().end(),
30-
[&](const cppast::cpp_token& tok) { return tok.spelling == name; });
28+
auto iter
29+
= std::find_if(attr.value().arguments().value().begin(),
30+
attr.value().arguments().value().end(),
31+
[&](const cppast::cpp_token& tok) { return tok.spelling == name; });
3132
return iter != attr.value().arguments().value().end();
3233
}
3334
else
@@ -42,8 +43,10 @@ const cppast::cpp_enum& get_enum(const cppast::cpp_entity_index& index,
4243
// it is an enum
4344
assert(param_type.kind() == cppast::cpp_type_kind::user_defined_t);
4445
// lookup definition
45-
auto& definition =
46-
static_cast<const cppast::cpp_user_defined_type&>(param_type).entity().get(index)[0u].get();
46+
auto& definition = static_cast<const cppast::cpp_user_defined_type&>(param_type)
47+
.entity()
48+
.get(index)[0u]
49+
.get();
4750

4851
assert(definition.kind() == cppast::cpp_entity_kind::enum_t);
4952
return static_cast<const cppast::cpp_enum&>(definition);

example/enum_to_string.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/// \file
66
/// Generates enum `to_string()` code.
77
///
8-
/// Given an input file, it will generate a to_string() function for all enums marked with [[generate::to_string]].
8+
/// Given an input file, it will generate a to_string() function for all enums marked with
9+
/// [[generate::to_string]].
910

1011
#include <iostream>
1112

@@ -43,8 +44,8 @@ void generate_to_string(const cppast::cpp_file& file)
4344
<< ":\n";
4445

4546
// attribute can be used to override the string
46-
if (auto attr =
47-
cppast::has_attribute(enumerator, "generate::to_string"))
47+
if (auto attr
48+
= cppast::has_attribute(enumerator, "generate::to_string"))
4849
std::cout << " return "
4950
<< attr.value().arguments().value().as_string()
5051
<< ";\n";

example/serialization.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/// \file
66
/// Serialization code generation.
77
///
8-
/// Given an input file, it will generate a serialize() function for each class marked with [[generate::serialize]].
8+
/// Given an input file, it will generate a serialize() function for each class marked with
9+
/// [[generate::serialize]].
910

1011
#include <iostream>
1112

0 commit comments

Comments
 (0)