Skip to content

Commit 4dab673

Browse files
authored
Update to clang-format-14 (#238)
Signed-off-by: Christian Vetter <[email protected]>
1 parent 6ba1b25 commit 4dab673

Some content is hidden

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

49 files changed

+14019
-10882
lines changed

.clang-format

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,53 @@
1+
# Clang-format v14 based configuration
2+
---
13
BasedOnStyle: Google
4+
Language: Cpp
5+
Standard: c++17
26
AccessModifierOffset: -4
3-
BreakBeforeBinaryOperators: true
4-
BreakBeforeTernaryOperators: true
7+
AllowShortFunctionsOnASingleLine : None
8+
AllowShortIfStatementsOnASingleLine: Never
9+
AllowShortLoopsOnASingleLine: false
10+
AlwaysBreakAfterDefinitionReturnType: All
511
BinPackParameters: false
12+
BreakBeforeBinaryOperators: All
13+
BreakBeforeBraces: Allman
14+
BreakBeforeTernaryOperators: true
15+
BreakConstructorInitializers: BeforeComma
616
ColumnLimit: 100
7-
DerivePointerBinding: false
8-
PenaltyBreakComment: 60
17+
PackConstructorInitializers: BinPack
18+
IndentCaseLabels : false
919
IndentWidth: 4
10-
TabWidth: 4
11-
BreakBeforeBraces: Allman
20+
PenaltyBreakComment: 60
21+
SortIncludes: Never
22+
SortUsingDeclarations: false
23+
SpacesInContainerLiterals: false
24+
SpacesInAngles: Always
1225
SpacesInParentheses: true
13-
SpacesInSquareBrackets: true
14-
SpacesInAngles: true
1526
SpaceInEmptyParentheses: true
16-
IndentCaseLabels : false
17-
AllowShortFunctionsOnASingleLine : false
18-
BreakConstructorInitializersBeforeComma: true
19-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
20-
AllowShortIfStatementsOnASingleLine: false
21-
AllowShortLoopsOnASingleLine: false
22-
AlwaysBreakAfterDefinitionReturnType: true
27+
SpacesInSquareBrackets: true
28+
SpaceInEmptyBlock: false
29+
TabWidth: 4
30+
Cpp11BracedListStyle: false
31+
SpaceBeforeCpp11BracedList: false
32+
SpacesInCStyleCastParentheses: false
33+
BreakBeforeBraces: Custom
34+
BraceWrapping:
35+
AfterCaseLabel: true
36+
AfterClass: true
37+
AfterControlStatement: Always
38+
AfterEnum: true
39+
AfterFunction: true
40+
AfterNamespace: true
41+
AfterObjCDeclaration: true
42+
AfterStruct: true
43+
AfterUnion: true
44+
AfterExternBlock: true
45+
BeforeCatch: true
46+
BeforeElse: true
47+
BeforeLambdaBody: false
48+
BeforeWhile: false
49+
IndentBraces: false
50+
SplitEmptyFunction: true
51+
SplitEmptyRecord: true
52+
SplitEmptyNamespace: true
53+
...

flatdata-cpp/benchmark/BreadthFirstSearch.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include <random>
77
#include <vector>
88

9-
/// Computes a simple Breath-First-Search. For big graphs this can mean a lot of random memory access.
9+
/// Computes a simple Breath-First-Search. For big graphs this can mean a lot of random memory
10+
/// access.
1011
template < typename Graph >
1112
void
1213
bfs( const Graph& graph, uint32_t num_iterations )
@@ -24,7 +25,7 @@ bfs( const Graph& graph, uint32_t num_iterations )
2425
{
2526
uint32_t id = q[ q_pos ];
2627
uint32_t depth = depths[ id ];
27-
auto edge = graph.edge( InternalId{id >> 1} );
28+
auto edge = graph.edge( InternalId{ id >> 1 } );
2829
auto edges
2930
= ( q[ q_pos ] & 1 ) == 0 ? edge.to_node( ).edges( ) : edge.from_node( ).edges( );
3031
for ( ; edges.valid( ); edges++ )

flatdata-cpp/benchmark/Dijkstra.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cost_function( Edge edge, Direction dir )
1313
{
1414
// A very simple (arbitrary) cost function that uses each attribute to benchmark reading all the
1515
// data;
16-
uint32_t multiplier[ 5 ] = {20, 19, 18, 17, 16};
16+
uint32_t multiplier[ 5 ] = { 20, 19, 18, 17, 16 };
1717
uint32_t divident = 200 * edge.speed_km_h( dir );
1818
uint32_t virtual_cost = 0;
1919
virtual_cost += edge.is_a( ) * 1;
@@ -82,7 +82,7 @@ dijkstra( const Graph& graph, uint32_t num_iterations )
8282
}
8383
num_nodes++;
8484
sum_cost += node.cost;
85-
auto edge = graph.edge( InternalId{node.id >> 1} );
85+
auto edge = graph.edge( InternalId{ node.id >> 1 } );
8686
auto edges
8787
= ( node.id & 1 ) == 0 ? edge.to_node( ).edges( ) : edge.from_node( ).edges( );
8888
for ( ; edges.valid( ); edges++ )
@@ -101,7 +101,6 @@ dijkstra( const Graph& graph, uint32_t num_iterations )
101101
}
102102
}
103103
std::cout << "Start " << ( ( ( start & 1 ) == 0 ) ? "+" : "-" ) << ( start >> 1 )
104-
<< " SumCosts: " << sum_cost
105-
<< " Queue Size: " << num_nodes << std::endl;
104+
<< " SumCosts: " << sum_cost << " Queue Size: " << num_nodes << std::endl;
106105
}
107106
}

flatdata-cpp/benchmark/FlatdataGraph.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ class FlatdataGraph
2626
InternalId
2727
id( ) const
2828
{
29-
return InternalId{m_id};
29+
return InternalId{ m_id };
3030
}
3131
ExternalId
3232
external_id( ) const
3333
{
34-
return ExternalId{m_data.id};
34+
return ExternalId{ m_data.id };
3535
}
3636
uint32_t
3737
length_m( ) const
@@ -108,11 +108,13 @@ class FlatdataGraph
108108
, m_graph( )
109109
{
110110
}
111-
void operator++( )
111+
void
112+
operator++( )
112113
{
113114
m_current++;
114115
}
115-
void operator++( int )
116+
void
117+
operator++( int )
116118
{
117119
m_current++;
118120
}
@@ -160,11 +162,13 @@ class FlatdataGraph
160162
, m_graph( )
161163
{
162164
}
163-
void operator++( )
165+
void
166+
operator++( )
164167
{
165168
m_current++;
166169
}
167-
void operator++( int )
170+
void
171+
operator++( int )
168172
{
169173
m_current++;
170174
}
@@ -181,12 +185,12 @@ class FlatdataGraph
181185
NodeId
182186
id( ) const
183187
{
184-
return NodeId{m_current};
188+
return NodeId{ m_current };
185189
}
186190
Coordinates
187191
coordinates( ) const
188192
{
189-
return Coordinates{m_graph->m_nodes[ m_current ].x, m_graph->m_nodes[ m_current ].y};
193+
return Coordinates{ m_graph->m_nodes[ m_current ].x, m_graph->m_nodes[ m_current ].y };
190194
}
191195
EdgeRange
192196
edges( ) const
@@ -240,7 +244,7 @@ class FlatdataGraph
240244

241245
for ( uint32_t i = 0; i < graph.edge_count( ); i++ )
242246
{
243-
auto edge = graph.edge( InternalId{i} );
247+
auto edge = graph.edge( InternalId{ i } );
244248
auto output_data = edge_data.grow( );
245249

246250
output_data.id = edge.external_id( ).id;

flatdata-cpp/benchmark/GraphGenerator.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,13 @@ inline GraphGenerator::NodeRange::NodeRange( uint32_t current, uint32_t end, uin
178178
, m_diameter( diameter )
179179
{
180180
}
181-
inline void GraphGenerator::NodeRange::operator++( )
181+
inline void
182+
GraphGenerator::NodeRange::operator++( )
182183
{
183184
m_current++;
184185
}
185-
inline void GraphGenerator::NodeRange::operator++( int )
186+
inline void
187+
GraphGenerator::NodeRange::operator++( int )
186188
{
187189
m_current++;
188190
}
@@ -199,7 +201,7 @@ GraphGenerator::NodeRange::size( ) const
199201
inline NodeId
200202
GraphGenerator::NodeRange::id( ) const
201203
{
202-
return NodeId{m_current};
204+
return NodeId{ m_current };
203205
}
204206
inline Coordinates
205207
GraphGenerator::NodeRange::coordinates( ) const
@@ -210,7 +212,7 @@ GraphGenerator::NodeRange::coordinates( ) const
210212
x |= y;
211213
y <<= 16;
212214
y |= x;
213-
return Coordinates{x, y};
215+
return Coordinates{ x, y };
214216
}
215217
inline GraphGenerator::EdgeRange
216218
GraphGenerator::NodeRange::edges( ) const
@@ -229,11 +231,13 @@ GraphGenerator::EdgeRange::EdgeRange( uint32_t node, uint32_t current, uint32_t
229231
, m_diameter( diameter )
230232
{
231233
}
232-
void GraphGenerator::EdgeRange::operator++( )
234+
void
235+
GraphGenerator::EdgeRange::operator++( )
233236
{
234237
m_current++;
235238
}
236-
void GraphGenerator::EdgeRange::operator++( int )
239+
void
240+
GraphGenerator::EdgeRange::operator++( int )
237241
{
238242
m_current++;
239243
}
@@ -276,12 +280,12 @@ GraphGenerator::Edge::Edge( uint32_t id, uint32_t diameter )
276280
InternalId
277281
GraphGenerator::Edge::id( ) const
278282
{
279-
return InternalId{m_id};
283+
return InternalId{ m_id };
280284
}
281285
ExternalId
282286
GraphGenerator::Edge::external_id( ) const
283287
{
284-
return ExternalId{( static_cast< uint64_t >( m_id ) << 32 ) | ( m_id * 13 )};
288+
return ExternalId{ ( static_cast< uint64_t >( m_id ) << 32 ) | ( m_id * 13 ) };
285289
}
286290
uint32_t
287291
GraphGenerator::Edge::length_m( ) const
@@ -308,15 +312,18 @@ GraphGenerator::Edge::is_d( ) const
308312
{
309313
return ( ( m_id % 7853 ) & 2 ) != 0;
310314
}
311-
bool GraphGenerator::Edge::is_e( Direction ) const
315+
bool
316+
GraphGenerator::Edge::is_e( Direction ) const
312317
{
313318
return ( ( m_id % 6967 ) & 2 ) != 0;
314319
}
315-
bool GraphGenerator::Edge::is_f( Direction ) const
320+
bool
321+
GraphGenerator::Edge::is_f( Direction ) const
316322
{
317323
return ( ( m_id % 5741 ) & 2 ) != 0;
318324
}
319-
bool GraphGenerator::Edge::is_g( Direction ) const
325+
bool
326+
GraphGenerator::Edge::is_g( Direction ) const
320327
{
321328
return ( ( m_id % 5881 ) & 2 ) != 0;
322329
}
@@ -342,7 +349,7 @@ GraphGenerator::Edge::frc( ) const
342349
uint8_t
343350
GraphGenerator::Edge::speed_km_h( Direction dir ) const
344351
{
345-
uint8_t table[ 5 ] = {30, 40, 50, 60, 70};
352+
uint8_t table[ 5 ] = { 30, 40, 50, 60, 70 };
346353
if ( dir == Direction::POSITIVE )
347354
return table[ frc( ) ];
348355
return table[ frc( ) ] - 1;

flatdata-cpp/benchmark/Lookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ lookup( const Graph& graph, uint32_t num_iterations )
1818

1919
for ( uint32_t edge_index = 0; edge_index < graph.edge_count( ); edge_index++ )
2020
{
21-
InternalId id{edge_index};
21+
InternalId id{ edge_index };
2222
auto edge = graph.edge( id );
2323
buckets[ dis( gen ) ].emplace_back( id, edge.external_id( ) );
2424
}

flatdata-cpp/benchmark/Printer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ print_graph( const Graph& graph )
3838

3939
for ( uint32_t i = 0; i < graph.edge_count( ); i++ )
4040
{
41-
print_edge( graph.edge( InternalId{i} ) );
41+
print_edge( graph.edge( InternalId{ i } ) );
4242
}
4343
}

flatdata-cpp/benchmark/StructGraph.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class StructGraph
5252
InternalId
5353
id( ) const
5454
{
55-
return InternalId{m_id};
55+
return InternalId{ m_id };
5656
}
5757
ExternalId
5858
external_id( ) const
@@ -211,7 +211,7 @@ class StructGraph
211211
NodeId
212212
id( ) const
213213
{
214-
return NodeId{m_current};
214+
return NodeId{ m_current };
215215
}
216216
Coordinates
217217
coordinates( ) const
@@ -288,7 +288,7 @@ class StructGraph
288288

289289
for ( uint32_t i = 0; i < graph.edge_count( ); i++ )
290290
{
291-
auto edge = graph.edge( InternalId{i} );
291+
auto edge = graph.edge( InternalId{ i } );
292292
auto& target = edge_data[ i ];
293293

294294
target.id = edge.external_id( );

flatdata-cpp/benchmark/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct DoPrint
107107
static void
108108
call( const Graph& graph )
109109
{
110-
measure( [&]( ) { print_graph( graph ); } );
110+
measure( [ & ]( ) { print_graph( graph ); } );
111111
}
112112
};
113113

@@ -117,7 +117,7 @@ struct DoBFS
117117
static void
118118
call( const Graph& graph, uint32_t num_runs )
119119
{
120-
measure( [&]( ) { bfs( graph, num_runs ); } );
120+
measure( [ & ]( ) { bfs( graph, num_runs ); } );
121121
}
122122
};
123123

@@ -127,7 +127,7 @@ struct DoDijkstra
127127
static void
128128
call( const Graph& graph, uint32_t num_runs )
129129
{
130-
measure( [&]( ) { dijkstra( graph, num_runs ); } );
130+
measure( [ & ]( ) { dijkstra( graph, num_runs ); } );
131131
}
132132
};
133133

@@ -137,7 +137,7 @@ struct DoLookup
137137
static void
138138
call( const Graph& graph, uint32_t num_runs )
139139
{
140-
measure( [&]( ) { lookup( graph, num_runs ); } );
140+
measure( [ & ]( ) { lookup( graph, num_runs ); } );
141141
}
142142
};
143143

@@ -199,15 +199,15 @@ or a flatdata archive.
199199
int
200200
main( int argc, char** argv )
201201
{
202-
auto args = docopt::docopt( USAGE, {argv + 1, argv + argc} );
202+
auto args = docopt::docopt( USAGE, { argv + 1, argv + argc } );
203203
try
204204
{
205205
size_t num_nodes = args.at( "--num-nodes" ).asLong( );
206206
size_t num_runs = args.at( "--num-runs" ).asLong( );
207207

208208
if ( args.at( "create" ).asBool( ) )
209209
{
210-
measure( [&]( ) { create( argv[ 2 ], num_nodes ); } );
210+
measure( [ & ]( ) { create( argv[ 2 ], num_nodes ); } );
211211
}
212212
else if ( args.at( "print" ).asBool( ) )
213213
{

0 commit comments

Comments
 (0)