etl/.clang-format
2026-04-02 08:20:43 +01:00

122 lines
5.0 KiB
YAML

---
BasedOnStyle: LLVM
Standard: Auto # let the formatter accept any C++ standard
# =============================================================================
# Indentation
# =============================================================================
TabWidth: 2
ContinuationIndentWidth: 2
ConstructorInitializerIndentWidth: 2
NamespaceIndentation: All # everything inside namespace is indented
IndentCaseLabels: true # case labels at switch-body indent level
IndentCaseBlocks: true # indent block inside case label
IndentExternBlock: Indent
IndentWrappedFunctionNames: true # keep function name at same indent as return type
IndentPPDirectives: BeforeHash # nested #if / #include get indented before the #
PPIndentWidth: 2
# =============================================================================
# Braces & line-break style
# =============================================================================
BreakBeforeBraces: Allman
BreakConstructorInitializers: BeforeComma # colon on new line, commas lead
BreakInheritanceList: BeforeComma
BreakBeforeBinaryOperators: NonAssignment
BreakStringLiterals: false
AlwaysBreakTemplateDeclarations: Yes # template <…> always on its own line
# =============================================================================
# Short statements
# =============================================================================
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty # only empty bodies: void f() {}
AllowShortCaseLabelsOnASingleLine: true # case X: stmt; break; on one line
AllowShortLoopsOnASingleLine: true
AllowShortLambdasOnASingleLine: Inline
# =============================================================================
# Empty lines
# =============================================================================
KeepEmptyLinesAtTheStartOfBlocks: false
EmptyLineBeforeAccessModifier: Always # blank line before public:/private:/protected:
EmptyLineAfterAccessModifier: Always # blank line after public:/private:/protected:
InsertNewlineAtEOF: true
# =============================================================================
# Spacing
# =============================================================================
SpacesInAngles: Leave # preserve C++03 "> >" vs C++11 ">>"
SpacesInContainerLiterals: false
# =============================================================================
# Alignment
# =============================================================================
PointerAlignment: Left # T* ptr, const T& ref
ReferenceAlignment: Left
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignConsecutiveBitFields: true
AlignConsecutiveMacros: true # align macro bodies
# =============================================================================
# Line length and wrapping
# =============================================================================
ColumnLimit: 0
ReflowComments: true # preserve hand-formatted comment rulers
# =============================================================================
# Includes
# =============================================================================
IncludeCategories:
- Regex: '^(<|")(.*/)?platform\.h(>|")$'
Priority: -1
# everything else gets the default priority (0)
# =============================================================================
# Arguments, parameters and constructor initialisers
# =============================================================================
PackConstructorInitializers: Never # each initialiser on its own line
# =============================================================================
# Namespaces and using declarations
# =============================================================================
SortUsingDeclarations: Lexicographic
# =============================================================================
# Macro-aware formatting
# =============================================================================
# ETL-specific macros that should be treated as statement-level constructs
StatementMacros:
- ETL_DECLARE_DEBUG_COUNT
- ETL_INCREMENT_DEBUG_COUNT
- ETL_DECREMENT_DEBUG_COUNT
- ETL_ADD_DEBUG_COUNT
- ETL_STATIC_ASSERT
# Macros that behave like attributes or specifiers.
AttributeMacros:
- ETL_NODISCARD
- ETL_NORETURN
- ETL_DEPRECATED
- ETL_CONSTEXPR
- ETL_CONSTEXPR14
Macros:
- ETL_CONSTEXPR=constexpr
- ETL_CONSTEXPR14=constexpr
- ETL_NODISCARD=[[nodiscard]]
- ETL_NORETURN=[[noreturn]]
- ETL_DEPRECATED=[[deprecated]]
# Macros that behave like type names
TypenameMacros:
- ETL_OR_STD
# Do not reformat these macros — they contain DSL-like content
WhitespaceSensitiveMacros:
- ETL_ERROR_TEXT
- ETL_DECLARE_ENUM_TYPE
- ETL_ENUM_TYPE
- ETL_END_ENUM_TYPE