# ReMoM house style — clang-format 20.x (pin to LLVM 20; see doc/#Devel/Devel-Clang.md)
#
# This file DESCRIBES the existing hand-written style so that formatting a
# freshly-touched file converges toward the tree instead of rewriting it.
# It is NOT safe to bulk-run over the whole tree: the codebase is heavily
# hand-aligned (column-aligned declarations, offset-annotated packed structs),
# and clang-format cannot reproduce that alignment. Format per-file as files
# are touched, and guard byte-layout tables with `// clang-format off/on`.
#
# Two knobs are load-bearing and were measured from the tree, not guessed:
#   PointerAlignment: Middle   ->  `Type * name`   (~2800 sites vs ~400 right)
#   SpaceBeforeParens: Never   ->  `if( for( while(` (~15700 sites vs ~90 spaced)
Language:                Cpp
BasedOnStyle:            LLVM

# Indentation / braces
UseTab:                  Never
IndentWidth:             4
TabWidth:                4
BreakBeforeBraces:       Allman
IndentCaseLabels:        true
AccessModifierOffset:    -4
NamespaceIndentation:    All
FixNamespaceComments:    false
IndentPPDirectives:      None

# Line handling — manual line breaks and blank-line section separators are
# load-bearing here, so do not reflow or collapse them.
ColumnLimit:             0
MaxEmptyLinesToKeep:     3
SortIncludes:            false
IncludeBlocks:           Preserve

# House spacing / pointer style (measured from the tree)
PointerAlignment:        Middle
SpaceBeforeParens:       Never

# Preserve the author's one-line idioms instead of forcing expansion. The tree
# deliberately uses them: ~763 braced one-line ifs, ~635 one-line case labels,
# ~487 unbraced guard-clause ifs, ~13 one-line functions. Under ColumnLimit: 0
# these "Allow" values KEEP an existing one-liner on one line WITHOUT collapsing
# an already-expanded block (verified empirically with clang-format 20).
AllowShortIfStatementsOnASingleLine:   AllIfsAndElse
AllowShortFunctionsOnASingleLine:      All
AllowShortLoopsOnASingleLine:          true
AllowShortBlocksOnASingleLine:         Always
AllowShortCaseLabelsOnASingleLine:     true

# Preserve the author's hand-alignment wherever clang-format supports "leave
# as-is". Consecutive alignment was measured to INCREASE churn (over-aligns),
# so it stays off.
AlignTrailingComments:
  Kind:            Leave
  OverEmptyLines:  0
AlignConsecutiveMacros:        None
AlignConsecutiveAssignments:   None
AlignConsecutiveDeclarations:  None

# Vertical multi-condition ifs: one condition per line, && / || at the END of
# the line, the closing ) on its own line (tested 2026-11-18, clang-format 20):
#     if(
#         (a == 1) &&
#         (b == 2)
#     )
# BlockIndent only covers the if( parenthesis: a vertical (...) group nested
# inside the condition is compacted to ((x) &&\n (y)).
BreakBeforeBinaryOperators:    None
AlignAfterOpenBracket:         BlockIndent
AlignOperands:                 DontAlign

# Brace initialisers keep their inner spaces: { 0, 0, 0 }, not {0, 0, 0} (house style for explicit zero-init).
Cpp11BracedListStyle:          false
