Skip to content

C/C++ function-defining macros are not counted as functions (6,074 of 6,437 in the DOOM corpus: DEFINE_ACTION_FUNCTION, CCMD, FUNC(...)) #5461

Closed

Description

@squid-protocol

Problem

DOOM ports define large families of functions through macros: DEFINE_ACTION_FUNCTION(AActor, A_Look) { ... }, CCMD(map) { ... }, CUSTOM_CVAR(Int, x, ...) { ... }, odamex FUNC(LS_Door_Open) { ... } where #define FUNC(a) static bool a (line_t *ln, ...). C/C++ func_start (gitgalaxy/standards/language_standards/languages/c.py:138, cpp.py:178) does not anchor on MACRO(name[, ...]) followed by a body, so none of these are functions: their complexity, LOC and calls are invisible or charged to the enclosing file. Universal Ctags misses most of them too, so ctags parity hides the gap.

Corpus measurement (first-party C/C++, line ^[A-Z][A-Z0-9_]{2,}\s*\(\s*name[, ...]\) followed by {): 6,437 definitions, 6,074 missed.

port macro defs missed
gzdoom 2,059 1,985
zandronum 1,554 1,554
vizdoom 1,242 1,242
doomsday 621 334
eternity 481 481
odamex 299 297 (p_lnspec.cpp: 188 FUNC handlers, GitGalaxy finds 5)
doom3-bfg 155 155
srb2 25 25

Class: macro-introduced definitions (top names)

DEFINE_ACTION_FUNCTION 1,473 · CCMD 932 · DEFINE_ACTION_FUNCTION_NATIVE 703 · CUSTOM_CVAR 570 · DEFINE_ACTION_FUNCTION_PARAMS 358 · CONSOLE_COMMAND 242 · BEGIN_COMMAND 234 · DEFINE_ACTION 228 · DEFINE_PROPERTY 220 · D_CMD 203 · DEFINE_MAP_OPTION 179 · DE_PIMPL 157 (class-like, out of scope as function) · DEFINE_CLASS_PROPERTY 156. Also outside DOOM: TEST(...)/TEST_F (gtest), PHP_FUNCTION, Py_* wrappers.

Acceptance

  • An all-caps macro invocation at line start whose argument list is followed by a function body { is recorded as a function (name = the identifier argument; ambiguous multi-arg forms use a documented rule, e.g. last identifier, or the macro name + first arg).
  • When the macro's #define is in the scanned tree and expands to a function signature, use it (odamex FUNC).
  • Not fired on if (X(y)) {-style control flow or struct initialisers; DE_PIMPL-style class macros stay out.
  • Fixture with gzdoom/odamex/gtest shapes; rescan gzdoom/zandronum/odamex: macro-defined handlers present.

Part of #5457 (milestone DOOM Port Speedrun).

Evidence: /srv/storage_16tb/projects/gitgalaxy/doom-study/ — round2_findings.md, clean_check.csv, clean_check_details.json; scans in scans_r2/<port>/ at engine 585c243e9; corpus variants_r2.csv (39 ports, pinned SHAs); scorer scripts/clean_check.py.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    metrics
    core-engine
    priority: high
    needs:doom-corpus
    scope:core
    on Oct 18, 2026
  2. squid-protocol commented on Oct 18, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host nyx, lease renewed 2026-10-18T22:38Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:nyx label.

  3. squid-protocol commented on Oct 18, 2026

    @squid-protocol
    OwnerAuthor

    Acceptance met: #5483 (macro-introduced definitions recorded as functions, same-file #define lookup for FUNC, TEST/gtest, control-flow guard) and #5545 (first-arg naming for DEFINE_PROPERTY/DEFINE_MAP_OPTION/DEFINE_CLASS_PROPERTY). Rescans of gzdoom/zandronum/odamex show the handlers present (odamex FUNC 188). Deliberate limits (column-0 only, same-file #define) are noted in the PRs and can be filed separately if a port needs them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaim:nyxcore-enginemetricsneeds:doom-corpuspriority: highscope:core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions