# C/C++ naming checks for runtime/ and tools/, the only directories with hand-written C/C++.
# generated/, externals/ and files generated into the build directory are not checked.
# Naming rules: Google C++ Style Guide with project-specific deviations.
Checks: '-*,readability-identifier-naming'

# Without a filter, diagnostics from every non-system header are shown, including
# third-party and generated ones. The exclude filter covers directories named
# runtime/ or tools/ inside externals/ and generated/.
HeaderFilterRegex: '(^|[/\\])(runtime|tools)[/\\]'
ExcludeHeaderFilterRegex: '(^|[/\\])(externals|generated)[/\\]'

CheckOptions:
  # --- Types (Google) ---
  readability-identifier-naming.ClassCase: CamelCase
  readability-identifier-naming.StructCase: CamelCase
  readability-identifier-naming.UnionCase: CamelCase
  readability-identifier-naming.EnumCase: CamelCase
  readability-identifier-naming.TypedefCase: CamelCase
  readability-identifier-naming.TypeAliasCase: CamelCase
  readability-identifier-naming.TypeTemplateParameterCase: CamelCase
  # STL-style member types (value_type, iterator, size_type, ...)
  readability-identifier-naming.TypedefIgnoredRegexp: '^[a-z]+(_[a-z]+)*$'
  readability-identifier-naming.TypeAliasIgnoredRegexp: '^[a-z]+(_[a-z]+)*$'

  # --- Functions (deviation: camelCase) ---
  readability-identifier-naming.FunctionCase: camelBack
  readability-identifier-naming.MethodCase: camelBack
  # Multi-word STL interface names. Single-word ones (begin, end, size, ...)
  # already pass camelBack. Anything rarer: use NOLINTBEGIN/NOLINTEND.
  readability-identifier-naming.MethodIgnoredRegexp: '^(push|pop|emplace)_(back|front)$|^max_size$'
  # Guest functions and import thunks keep the recompiler's names (fn_%08x, imp_%08x,
  # with a module prefix for non-main images), so overrides match the generated code.
  readability-identifier-naming.FunctionIgnoredRegexp: '^([a-z0-9]+_)?(fn|imp)_[0-9a-f]{8}$'

  # --- Variables (Google) ---
  readability-identifier-naming.VariableCase: lower_case
  readability-identifier-naming.ParameterCase: lower_case
  # Deviation: locals may also be camelCase
  readability-identifier-naming.LocalVariableCase: lower_case
  readability-identifier-naming.LocalVariableIgnoredRegexp: '^[a-z][a-zA-Z0-9]*$'
  readability-identifier-naming.LocalConstantCase: lower_case
  readability-identifier-naming.LocalConstantIgnoredRegexp: '^[a-z][a-zA-Z0-9]*$'

  # --- Data members (Google) ---
  readability-identifier-naming.PrivateMemberCase: lower_case
  readability-identifier-naming.PrivateMemberSuffix: _
  readability-identifier-naming.ProtectedMemberCase: lower_case
  readability-identifier-naming.ProtectedMemberSuffix: _
  readability-identifier-naming.PublicMemberCase: lower_case

  # --- Constants (Google) ---
  readability-identifier-naming.ConstexprVariableCase: CamelCase
  readability-identifier-naming.ConstexprVariablePrefix: k
  readability-identifier-naming.GlobalConstantCase: CamelCase
  readability-identifier-naming.GlobalConstantPrefix: k
  readability-identifier-naming.StaticConstantCase: CamelCase
  readability-identifier-naming.StaticConstantPrefix: k
  readability-identifier-naming.ClassConstantCase: CamelCase
  readability-identifier-naming.ClassConstantPrefix: k
  # Deviation: a constant whose value is obtained at run time (counter frequency, page
  # size, a lazily created handle) is named like a variable; k marks values fixed in source.
  readability-identifier-naming.StaticConstantIgnoredRegexp: '^[a-z][a-z0-9_]*$'
  readability-identifier-naming.GlobalConstantIgnoredRegexp: '^g_[a-z0-9_]+$'

  # --- Enumerators (deviation: enum class constants take no k prefix) ---
  readability-identifier-naming.EnumConstantCase: CamelCase
  # Unscoped enumerators may also use the k prefix: C has no constexpr, so an anonymous
  # enum serves as a constant there, and the C headers shared with recompiler output
  # spell their constants kSshd*.
  readability-identifier-naming.EnumConstantIgnoredRegexp: '^k[A-Z][A-Za-z0-9]*$'
  readability-identifier-naming.ScopedEnumConstantCase: CamelCase

  # --- Others (Google) ---
  readability-identifier-naming.NamespaceCase: lower_case
  readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
