Skip to content

fix(c/cpp): seed preproc_else/elif as parallel reachability entries #5357

Description

@scarsnow

Summary

Follow-up from #5338 (graphify-labs P2).

When walk_calls treats an unconditional return as ending fall-through inside a #if / #ifdef body, sibling preproc_else / preproc_elif nodes must not be skipped. Those branches are alternate build configurations, not dead code after the return.

Expected

  • Same-branch calls after return; stay omitted (CubeMX-style tails).
  • Calls inside #else / #elif remain extracted as reachable under another configuration.

Suggested approach

Reuse the C/C++ reachability seeding used for switch case entries in #5338: when walking a preproc_if / preproc_ifdef, also seed preproc_else / preproc_elif children as parallel entry points.

Related

Activity

  1. github-actions commented on Nov 20, 2026

    @github-actions

    Thanks for opening this issue, @scarsnow. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. scarsnow commented on Nov 20, 2026

    @scarsnow
    Author

    Reproduce (current c-return-reachability / after #5338 reachability)

    void f(void) {
    #if FEATURE
      a();
      return;
      dead();
    #else
      b();
    #endif
      after();
    }

    Actual (extracted calls from f()): a(), after() — missing b()
    Expected: a(), b(), after() — still omit dead()

    Confirmed with graphify.extract on this fixture: same-branch dead code after return is correctly dropped, but the #else call is skipped too.

  3. scarsnow commented on Nov 23, 2026

    @scarsnow
    Author

    Verified on current v8 tip (a3db62f) — attribution + branches

    Follow-up to the repro in #5357 (comment).

    Sources (who owns what)

    Piece Source
    return / goto / case / static infinite-loop reachability scarsnow — #5338 (rebased onto a3db62f)
    Seed preproc_else / preproc_elif as parallel entries + #5357 tests Deepjyoti-Sarmah — #5365 (27bfc28d, 13722544 / originally 551874a lineage)
    Base Graphify-Labs/graphify@a3db62f

    What we submitted

    1. #5338 force-updated to scarsnow/c-return-reachability @ 95e6b3c7 — only the three scarsnow commits on a3db62f (does not absorb fix(c/cpp): keep #elif/#else calls after a return in a #if branch (stacked on #5338) #5365). Schema comment claims #5338 only.
    2. Combined verify branch (no competing PR): scarsnow/verify/a3db62f-5338-5365 @ 13722544 = a3db62f + fix(c-cpp): skip calls in code no path can reach #5338 commits + Deepjyoti-Sarmah’s two fix(c/cpp): keep #elif/#else calls after a return in a #if branch (stacked on #5338) #5365 commits (authorship preserved).

    Result on the combined tip

    Please keep landing the #else / #elif seed via #5365; #5338 stays the return/goto/case stack only. Happy to drop the verify branch once #5365 merges onto the same base.

  4. scarsnow commented on Nov 24, 2026

    @scarsnow
    Author

    Update: the parallel-seed fix from #5365 is now also on #5338 tip (6d53e5c7), so alternate #elif/#else calls after a return in another arm are kept under the existing multi-world-union model.

  5. added 2 commits that reference this issue on Nov 24, 2026
  6. scarsnow commented on Nov 27, 2026

    @scarsnow
    Author

    Status: this is fixed on the current #5338 tip (1d49d69f, merged with v8 0.9.121), and #5338 is linked to close this issue.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions