Skip to content

Commit

Permalink
Add a .clang-format file to WIL (#412)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dunhor authored Dec 15, 2023
1 parent c0cd23f commit 572b872
Show file tree
Hide file tree
Showing 61 changed files with 42,288 additions and 35,609 deletions.
231 changes: 231 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
---
Language: Cpp
# BasedOnStyle: LLVM

AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
ColumnLimit: 130
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Regroup
IndentCaseLabels: false
IncludeCategories:
- Regex: '^"(stdafx.h|pch.h|precomp.h)"$'
Priority: -1
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
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$'
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$'
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 2000
PenaltyExcessCharacter: 2
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 4
UseTab: Never

AttributeMacros: [
CALLBACK,
]

StatementMacros: [
_Acquires_exclusive_lock_,
_Acquires_lock_,
_Acquires_nonreentrant_lock_,
_Acquires_shared_lock_,
_Analysis_assume_smart_lock_acquired_,
_Analysis_assume_smart_lock_released_,
_Create_lock_level_,
_Detaches_lock_,
_Function_class_,
_Global_cancel_spin_lock_,
_Global_critical_region_,
_Global_interlock_,
_Global_priority_region_,
_Has_lock_kind_,
_Has_lock_level_,
_IRQL_always_function_max_,
_IRQL_always_function_min_,
_IRQL_raises_,
_IRQL_requires_,
_IRQL_requires_max_,
_IRQL_requires_min_,
_IRQL_requires_same_,
_IRQL_restores_,
_IRQL_restores_global_,
_IRQL_saves_,
_IRQL_saves_global_,
_Lock_level_order_,
_Moves_lock_,
_Must_inspect_result_,
_No_competing_thread_,
_Post_same_lock_,
_Post_writable_byte_size_,
_Pre_satisfies_,
_Releases_exclusive_lock_,
_Releases_lock_,
_Releases_nonreentrant_lock_,
_Releases_shared_lock_,
_Replaces_lock_,
_Requires_exclusive_lock_held_,
_Requires_lock_held_,
_Requires_lock_not_held_,
_Requires_no_locks_held_,
_Requires_shared_lock_held_,
_Ret_maybenull_,
_Ret_range_,
_Struct_size_bytes_,
_Success_,
_Swaps_locks_,
_Use_decl_annotations_,
_When_,

DECLARE_ORDINAL_MAP,
DECLARE_PROCNAME_MAP,
DEFINE_ORDINAL_ENTRIES,
DEFINE_ORDINAL_ENTRIES_ALTNAME,
DEFINE_ORDINAL_ENTRIES_APISET,
DEFINE_ORDINAL_MAP,
DEFINE_PROCNAME_ENTRIES,
DEFINE_PROCNAME_ENTRIES_ALTNAME,
DEFINE_PROCNAME_ENTRIES_APISET,
DEFINE_PROCNAME_MAP,
DLOENTRY,
DLOENTRY_APISET,
DLPENTRY,
DLPENTRY_APISET,

RpcEndExcept,

ActivatableClass,
ActivatableClassWithFactory,
ActivatableClassWithFactoryEx,
ActivatableStaticOnlyFactory,
ActivatableStaticOnlyFactoryEx,
CoCreatableClass,
CoCreatableClassWithFactory,
CoCreatableClassWithFactoryEx,

# Additional definitions for the WIL repo
_Translates_NTSTATUS_to_HRESULT_,
_Translates_Win32_to_HRESULT_,
_Translates_last_error_to_HRESULT_,
]

TypenameMacros: [
IFACEMETHOD,
STDMETHOD,
STDAPI_,
]

# Additional definitions for the WIL repo
WhitespaceSensitiveMacros: [
__WI_CLANG_DISABLE_WARNING,
]

# TODO: Only supported by clang-format version 17+
# Macros:
# - WI_NOEXCEPT=noexcept
# - __R_FN_PARAMS_FULL=int x
# - RESULT_NORETURN=[[noreturn]]
---
Language: CSharp
AlignAfterOpenBracket: AlwaysBreak
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
BeforeCatch: true
BeforeElse: true
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBraces: Custom
ColumnLimit: 130
DerivePointerAlignment: false
IndentWidth: 4
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 2000
PenaltyExcessCharacter: 2
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
TabWidth: 4
UseTab: Never
...

Loading

0 comments on commit 572b872

Please sign in to comment.