-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path.clang-format
More file actions
128 lines (100 loc) · 5.11 KB
/
Copy path.clang-format
File metadata and controls
128 lines (100 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
# ==============================================================================
# 1. Base Style and Indentation
# (Controls the fundamental structure and spacing)
# ==============================================================================
BasedOnStyle: LLVM
Language: Cpp
# Set the maximum line width for wrapping. (LLVM default is 80)
ColumnLimit: 100
# Set the block indentation width to 2 spaces for a more compact style. (LLVM default is 4)
IndentWidth: 2
# Place the pointer/reference symbol (e.g., '*' or '&') on the left, next to the type.
# Example: int* x; (Instead of int *x;)
PointerAlignment: Left
# Penalty for placing the return type of a long function on its own line.
# High penalty (1000) strongly discourages putting the return type on a separate line.
PenaltyReturnTypeOnItsOwnLine: 1000
# ==============================================================================
# 2. Line Wrapping and Single-Line Control
# (Strictly enforces multi-line structure for better readability)
# ==============================================================================
# Forces a break after the 'template <...>' part of a template declaration.
AlwaysBreakTemplateDeclarations: true
# Forcing multi-line structure for short blocks (high readability requirement).
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
# Note: Functions are also forced to multi-line via 'AllowShortFunctionsOnASingleLine: None'
AllowShortFunctionsOnASingleLine: None
# ==============================================================================
# 3. Declarations, Parameters, and Alignment
# (Controls function signatures, initializers, and variable alignment)
# ==============================================================================
# Parameter Packing (Function Definition/Declaration):
# Allow function parameters to be packed on one line if they fit.
BinPackParameters: true
# If parameters must wrap, allow all parameters to be moved to the next line.
AllowAllParametersOfDeclarationOnNextLine: true
# Argument Packing (Function Call):
# Allow function call arguments to be packed on one line if they fit.
BinPackArguments: true
# If arguments must wrap, allow all arguments to be moved to the next line.
AllowAllArgumentsOnNextLine: true
# Alignment of elements after an open parenthesis or bracket.
# 'Align' means alignment will be relative to the open bracket itself.
AlignAfterOpenBracket: Align
# Constructor Initializer List Formatting:
# Put initializers on the current line if possible, wrapping to the next line only when needed.
PackConstructorInitializers: CurrentLine
# C++11 Uniform Initialization:
# Use extra indentation for braced lists ({...}) in C++11 style.
Cpp11BracedListStyle: true
# ==============================================================================
# 4. Access Modifiers and Qualifiers
# (Controls keywords like 'public' and 'const')
# ==============================================================================
# Forces an empty line before access specifiers (public:, private:, protected:).
EmptyLineBeforeAccessModifier: Always
# Enforce a specific, custom order for type qualifiers (const, static, etc.).
QualifierAlignment: Custom
QualifierOrder: ['inline', 'static', 'constexpr', 'const', 'volatile', 'type']
# ==============================================================================
# 5. Include Header Sorting and Grouping
# (Strictly controls the order of includes based on source of file)
# ==============================================================================
# Defines the style of include blocks: regroup means adjacent includes of the same priority
# are grouped together, and different groups are separated by empty lines.
IncludeBlocks: Regroup
# Defines the specific sorting order using Regular Expressions and assigned Priority.
# Lower Priority number means the group comes first.
IncludeCategories:
# Priority 2 (Highest Priority: Project-Specific Headers)
# 1. Matching header file for the current source file (e.g., "file.hpp").
- Regex: '^".*.hpp'
Priority: 2
# 2. Internal Project Core Library includes (e.g., "leanstore/...")
- Regex: '^("|<)leanstore/*'
Priority: 2
# Priority 3 (Internal Tools / Specific Third-Party Tools)
- Regex: '^("|<)(benchmark)/'
Priority: 3
# Priority 4 (Major External Third-Party Libraries - Tier 1)
# Includes Boost, Google Test, Spdlog, RocksDB, etc.
- Regex: '^("|<)(tanakh-cmdline|concurrentqueue|cpptrace|boost|gtest|gmock|spdlog|glog|rapidjson|rocksdb|wiredtiger|gperftools|crc32c|prometheus)/'
Priority: 4
# Specific external library (httplib)
- Regex: '^("|<)(httplib)'
Priority: 4
# Specific external library (wiredtiger)
- Regex: '^("|<)(wiredtiger)'
Priority: 4
# Priority 5 (Standard C++ Library Headers)
# Matches system headers without dots (e.g., <vector>, <iostream>)
- Regex: '<[[:alnum:]_/]+>'
Priority: 5
# Priority 6 (C/POSIX System Headers)
# Matches system headers that might contain a dot (e.g., <sys/stat.h>, <cstdint>)
- Regex: '<[[:alnum:]_/.]+>'
Priority: 6