Skip to content

C++: Make asExpr return AggregateLiterals #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MathiasVP
Copy link
Collaborator

This PR solves the same problem as #227, but unlike that PR this one:

  • Also works for recursive uses of aggregate literals (🎉)
  • However, it doesn't work for array aggregate literals (😭)

Instead of creating a new kind of SSA read, and a new DataFlow::Node branch, this PR makes node.asExpr() instanceof ClassAggregateLiteral hold when node is the post-update node generated from the last field write in the class aggregate initialization. This is semantically the perfect node to pick since it does represent the fully initialized aggregate. So I'm pretty happy with that!

However, it relies on the presence of post-update nodes when initializing aggregates. This holds for class aggregate literals (since they are represented as a sequence of field writes), but it doesn't work for array aggregates (since we don't model array writes using post-update nodes).

I think the solution is to go with this approach and then I'll work on actually modeling array writes as using post-update nodes since this is something I've been wanting to do for a while anyway since it'll give us better precision in dataflow.

TLDR @bdrodes: This is the PR that I want to upstream. It works for class aggregate literals (which is where you brought up this issue to me again), but it doesn't work for array aggregate literals (which was the original issue you brought to my attention earl last year which I recorded in https://github.com/github/codeql-c-team/issues/2153).

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.

1 participant