Skip to content

Commit 572b872

Browse files
authored
Add a .clang-format file to WIL (#412)
* Squash to single commit * Don't format C++/CX hat pointers * Don't format WRL * Messed up the scripts * A few more SAL annotations to make things slightly better in places * Merge issue
1 parent c0cd23f commit 572b872

Some content is hidden

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

61 files changed

+42288
-35609
lines changed

.clang-format

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
5+
AccessModifierOffset: -4
6+
AlignAfterOpenBracket: AlwaysBreak
7+
AlignConsecutiveAssignments: false
8+
AlignEscapedNewlines: DontAlign
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: None
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLambdasOnASingleLine: Empty
17+
AllowShortLoopsOnASingleLine: false
18+
AlwaysBreakAfterDefinitionReturnType: None
19+
AlwaysBreakAfterReturnType: None
20+
AlwaysBreakBeforeMultilineStrings: true
21+
AlwaysBreakTemplateDeclarations: true
22+
BinPackArguments: false
23+
BinPackParameters: false
24+
BraceWrapping:
25+
AfterCaseLabel: true
26+
AfterClass: true
27+
AfterControlStatement: true
28+
AfterEnum: true
29+
AfterFunction: true
30+
AfterNamespace: true
31+
AfterStruct: true
32+
AfterUnion: true
33+
AfterExternBlock: true
34+
BeforeCatch: true
35+
BeforeElse: true
36+
SplitEmptyFunction: true
37+
SplitEmptyRecord: true
38+
SplitEmptyNamespace: true
39+
BreakBeforeBinaryOperators: None
40+
BreakBeforeBraces: Custom
41+
BreakBeforeTernaryOperators: true
42+
BreakConstructorInitializers: AfterColon
43+
BreakStringLiterals: false
44+
ColumnLimit: 130
45+
CommentPragmas: '^ IWYU pragma:'
46+
CompactNamespaces: true
47+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
48+
ConstructorInitializerIndentWidth: 4
49+
ContinuationIndentWidth: 4
50+
Cpp11BracedListStyle: true
51+
DerivePointerAlignment: false
52+
DisableFormat: false
53+
FixNamespaceComments: true
54+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
55+
IncludeBlocks: Regroup
56+
IndentCaseLabels: false
57+
IncludeCategories:
58+
- Regex: '^"(stdafx.h|pch.h|precomp.h)"$'
59+
Priority: -1
60+
IndentWidth: 4
61+
IndentWrappedFunctionNames: false
62+
KeepEmptyLinesAtTheStartOfBlocks: true
63+
MacroBlockBegin: '^BEGIN_COM_MAP$|^BEGIN_CONNECTION_POINT_MAP$|^BEGIN_HELPER_NODEMAP$|^BEGIN_MODULE$|^BEGIN_MSG_MAP$|^BEGIN_OBJECT_MAP$|^BEGIN_TEST_CLASS$|^BEGIN_TEST_METHOD$|^BEGIN_TEST_METHOD_PROPERTIES$'
64+
MacroBlockEnd: '^END_COM_MAP$|^END_CONNECTION_POINT_MAP$|^END_HELPER_NODEMAP$|^END_MODULE$|^END_MSG_MAP$|^END_OBJECT_MAP$|^END_TEST_CLASS$|^END_TEST_METHOD$|^END_TEST_METHOD_PROPERTIES$'
65+
MaxEmptyLinesToKeep: 1
66+
NamespaceIndentation: Inner
67+
ObjCBlockIndentWidth: 2
68+
ObjCSpaceAfterProperty: false
69+
ObjCSpaceBeforeProtocolList: true
70+
PenaltyBreakBeforeFirstCallParameter: 19
71+
PenaltyBreakComment: 300
72+
PenaltyBreakFirstLessLess: 120
73+
PenaltyBreakString: 2000
74+
PenaltyExcessCharacter: 2
75+
PenaltyReturnTypeOnItsOwnLine: 1000
76+
PointerAlignment: Left
77+
SortIncludes: false
78+
SpaceAfterCStyleCast: false
79+
SpaceBeforeAssignmentOperators: true
80+
SpaceBeforeParens: ControlStatements
81+
SpaceInEmptyParentheses: false
82+
SpacesBeforeTrailingComments: 1
83+
SpacesInAngles: Never
84+
SpacesInContainerLiterals: true
85+
SpacesInCStyleCastParentheses: false
86+
SpacesInParentheses: false
87+
SpacesInSquareBrackets: false
88+
Standard: Latest
89+
TabWidth: 4
90+
UseTab: Never
91+
92+
AttributeMacros: [
93+
CALLBACK,
94+
]
95+
96+
StatementMacros: [
97+
_Acquires_exclusive_lock_,
98+
_Acquires_lock_,
99+
_Acquires_nonreentrant_lock_,
100+
_Acquires_shared_lock_,
101+
_Analysis_assume_smart_lock_acquired_,
102+
_Analysis_assume_smart_lock_released_,
103+
_Create_lock_level_,
104+
_Detaches_lock_,
105+
_Function_class_,
106+
_Global_cancel_spin_lock_,
107+
_Global_critical_region_,
108+
_Global_interlock_,
109+
_Global_priority_region_,
110+
_Has_lock_kind_,
111+
_Has_lock_level_,
112+
_IRQL_always_function_max_,
113+
_IRQL_always_function_min_,
114+
_IRQL_raises_,
115+
_IRQL_requires_,
116+
_IRQL_requires_max_,
117+
_IRQL_requires_min_,
118+
_IRQL_requires_same_,
119+
_IRQL_restores_,
120+
_IRQL_restores_global_,
121+
_IRQL_saves_,
122+
_IRQL_saves_global_,
123+
_Lock_level_order_,
124+
_Moves_lock_,
125+
_Must_inspect_result_,
126+
_No_competing_thread_,
127+
_Post_same_lock_,
128+
_Post_writable_byte_size_,
129+
_Pre_satisfies_,
130+
_Releases_exclusive_lock_,
131+
_Releases_lock_,
132+
_Releases_nonreentrant_lock_,
133+
_Releases_shared_lock_,
134+
_Replaces_lock_,
135+
_Requires_exclusive_lock_held_,
136+
_Requires_lock_held_,
137+
_Requires_lock_not_held_,
138+
_Requires_no_locks_held_,
139+
_Requires_shared_lock_held_,
140+
_Ret_maybenull_,
141+
_Ret_range_,
142+
_Struct_size_bytes_,
143+
_Success_,
144+
_Swaps_locks_,
145+
_Use_decl_annotations_,
146+
_When_,
147+
148+
DECLARE_ORDINAL_MAP,
149+
DECLARE_PROCNAME_MAP,
150+
DEFINE_ORDINAL_ENTRIES,
151+
DEFINE_ORDINAL_ENTRIES_ALTNAME,
152+
DEFINE_ORDINAL_ENTRIES_APISET,
153+
DEFINE_ORDINAL_MAP,
154+
DEFINE_PROCNAME_ENTRIES,
155+
DEFINE_PROCNAME_ENTRIES_ALTNAME,
156+
DEFINE_PROCNAME_ENTRIES_APISET,
157+
DEFINE_PROCNAME_MAP,
158+
DLOENTRY,
159+
DLOENTRY_APISET,
160+
DLPENTRY,
161+
DLPENTRY_APISET,
162+
163+
RpcEndExcept,
164+
165+
ActivatableClass,
166+
ActivatableClassWithFactory,
167+
ActivatableClassWithFactoryEx,
168+
ActivatableStaticOnlyFactory,
169+
ActivatableStaticOnlyFactoryEx,
170+
CoCreatableClass,
171+
CoCreatableClassWithFactory,
172+
CoCreatableClassWithFactoryEx,
173+
174+
# Additional definitions for the WIL repo
175+
_Translates_NTSTATUS_to_HRESULT_,
176+
_Translates_Win32_to_HRESULT_,
177+
_Translates_last_error_to_HRESULT_,
178+
]
179+
180+
TypenameMacros: [
181+
IFACEMETHOD,
182+
STDMETHOD,
183+
STDAPI_,
184+
]
185+
186+
# Additional definitions for the WIL repo
187+
WhitespaceSensitiveMacros: [
188+
__WI_CLANG_DISABLE_WARNING,
189+
]
190+
191+
# TODO: Only supported by clang-format version 17+
192+
# Macros:
193+
# - WI_NOEXCEPT=noexcept
194+
# - __R_FN_PARAMS_FULL=int x
195+
# - RESULT_NORETURN=[[noreturn]]
196+
---
197+
Language: CSharp
198+
AlignAfterOpenBracket: AlwaysBreak
199+
AllowShortBlocksOnASingleLine: false
200+
AllowShortCaseLabelsOnASingleLine: false
201+
AllowShortFunctionsOnASingleLine: None
202+
AllowShortIfStatementsOnASingleLine: false
203+
AllowShortLoopsOnASingleLine: false
204+
BraceWrapping:
205+
AfterCaseLabel: true
206+
AfterClass: true
207+
AfterControlStatement: true
208+
AfterEnum: true
209+
AfterFunction: true
210+
AfterNamespace: true
211+
AfterStruct: true
212+
BeforeCatch: true
213+
BeforeElse: true
214+
SplitEmptyFunction: true
215+
SplitEmptyRecord: true
216+
SplitEmptyNamespace: true
217+
BreakBeforeBraces: Custom
218+
ColumnLimit: 130
219+
DerivePointerAlignment: false
220+
IndentWidth: 4
221+
PenaltyBreakBeforeFirstCallParameter: 19
222+
PenaltyBreakComment: 300
223+
PenaltyBreakFirstLessLess: 120
224+
PenaltyBreakString: 2000
225+
PenaltyExcessCharacter: 2
226+
PenaltyReturnTypeOnItsOwnLine: 1000
227+
PointerAlignment: Left
228+
TabWidth: 4
229+
UseTab: Never
230+
...
231+

0 commit comments

Comments
 (0)