macro_via: disjunctive #undef terminators leave dead macros live

Open
#193 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
compilers

Research direction

Start with src/database/macro_via.rs and read the deferred change in commit a2fe71e, focusing on guard overlap and how #undef terminators are handled. Use the C reproducer to check callers of target; done means the query no longer reports a via RUN edge when the combined #undef RUN guards cover every build.

Written by the indexing model from the issue text.

Description

When a function-like macro is #undef'd across multiple complementary preprocessor branches, macro_via treats each terminator independently and leaves the macro live, producing a false caller edge.

Reproducer

int target(void) { return 1; }
#define RUN(f) f()
#define FLAG 1
#if BRANCH
#undef RUN
#undef FLAG
#endif
#ifdef FLAG
#undef RUN
#endif
int caller(void) { return RUN(target); }

Querying callers of target reports caller via RUN, even though RUN is undefined in every build (BRANCH undefines RUN and FLAG; !BRANCH keeps FLAG defined and undefines RUN).

Cause

Deferred in a2fe71e: each #undef is uncertain on its own, and the guard overlap engine in src/database/macro_via.rs does not yet prove disjunctive terminator coverage across branches.

Expected behavior

callers target should not report a via RUN edge when the union of #undef RUN guards covers every build.

Dominant language
Rust
Stars
187
Forks
53
Avg merge
1d 9h
Merged PRs (30d)
79

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from facebookexperimental/semcode

All issues in facebookexperimental/semcode

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.