# UnrealIRCd code style for clang-format. We use clang-format v21.
# This tries to match our existing style as much as possible.

BasedOnStyle: LLVM

# Indentation: tabs to indent (width 8), spaces to align.
UseTab: ForIndentation
IndentWidth: 8
TabWidth: 8

# Braces: Allman for functions and control flow; attached (K&R) for
# struct/union/enum. 'else' stays cuddled to the closing brace ("} else") with
# the block's '{' on the next line.
BreakBeforeBraces: Custom
BraceWrapping:
  AfterCaseLabel: true
  AfterClass: false
  AfterControlStatement: Always
  AfterEnum: false
  AfterExternBlock: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: false
  AfterUnion: false
  BeforeCatch: true
  BeforeElse: false
  BeforeWhile: false
  IndentBraces: false
  SplitEmptyFunction: true
  SplitEmptyRecord: false

# Indent #define etc. inside #if blocks (one space per level), as the code already does.
IndentPPDirectives: BeforeHash
PPIndentWidth: 1

# Keep existing #define-value and trailing-comment column alignment (not declarations).
AlignConsecutiveMacros:
  Enabled: true
AlignTrailingComments:
  Kind: Always
  OverEmptyLines: 0

IndentCaseLabels: true                 # case labels are indented one level
SpaceBeforeParens: ControlStatements   # "if (" but "call(" / "sizeof("
PointerAlignment: Right                # "type *name"
DerivePointerAlignment: false
BreakBeforeBinaryOperators: None       # wrap after && / ||, not before
AllowShortFunctionsOnASingleLine: None
AllowShortEnumsOnASingleLine: false
SortIncludes: Never
SeparateDefinitionBlocks: Leave
AlignEscapedNewlines: DontAlign        # don't pad macro \ continuations
ColumnLimit: 0                         # never re-wrap lines on width
MaxEmptyLinesToKeep: 2
ReflowComments: false                  # leave comments as-is
