Skip to content

Conversation

@MathiasVP
Copy link
Collaborator

#304 added a new library for "macro flow". (See that description for what the library does.) Taking the example from that PR and changing it to:

#define DEBUG 1

#define MY_SIZEOF(x) sizeof(x)

#ifdef DEBUG
#define MY_FOO(y) MY_SIZEOF(y) + 1
#else
#define MY_FOO(y) 0
#endif

int test() {
  return MY_FOO(int);
}

No path is generated since MY_FOO(int) doesn't expand to exactly sizeof(int), but rather to a larger expression of which sizeof(int) is a subexpression.

With this PR we can now write:

// ...
from Flow::Node n1, Flow::Node n2, Expr e
where Flow::flowsTo(n1, n2, e, true)
select e, n1, n2, "Use of sizeof with integer type."

to keep the old behavior (i.e., only show paths when the expanded expression is exactly sizeof(int)), but we can also change true to _ to allow paths to only be generated when the sizeof(int) is a subexpression of the expanded macro.

@MathiasVP MathiasVP merged commit 1ad548b into main Dec 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants