The Wayback Machine - https://web.archive.org/web/20250522054650/https://github.com/github/codeql/pull/3879
Skip to content

C++: match extractor changes to two-operand ?: representation #3879

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

Closed
wants to merge 8 commits into from

Conversation

nickrolfe
Copy link
Contributor

Closes https://github.com/github/codeql-c-extractor-team/issues/67

Now the extractor emits a synthesized expr node for the 'then' case.

I've updated the question_mark_colon test to show that the 'then' expr now includes any implicit cast.

The upgrade script populates the missing expr_cond_true tuples by re-using the guard expr (just like the old implementation of getThen()).

I could use some assistance in judging whether the new results for the consistency queries are a problem.

@nickrolfe nickrolfe added C++ depends on internal PR This PR should only be merged in sync with an internal Semmle PR labels Jul 2, 2020
@nickrolfe nickrolfe requested a review from dbartol July 2, 2020 17:34
@nickrolfe nickrolfe requested a review from a team as a code owner July 2, 2020 17:34
@rdmarsh2
Copy link
Contributor

rdmarsh2 commented Jul 6, 2020

I think both the consistency query results and the simple range analysis changes will need library fixes.

@nickrolfe
Copy link
Contributor Author

I think there is an extractor issue for cases where there isn't an implicit cast on the 'then' expr. I'm investigating.

@nickrolfe
Copy link
Contributor Author

That extractor issue has been fixed, but the consistency query and simple range analysis results haven't changed. I'm not sure what kind of library changes are required there.

Copy link
Contributor

@dbartol dbartol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question for you, not blocking merge.

# 1308| expr: [ParenthesisExpr] (...)
# 1308| Type = [BoolType] bool
# 1308| ValueCategory = prvalue
# 1308| expr: [LogicalOrExpr] ... || ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the exact same expression object as child 0, or is it a copy? What happens if operand 0 might have side effects, as in foo() ?: 7?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, this is a separate entity in the db, but getting the same entity is possible, such as in your foo() example.

You can see an example of an expr being reused like that in question_mark_colon/types.expected that I added in this PR.

@dbartol
Copy link
Contributor

dbartol commented Jul 7, 2020

@jbj Are you OK with us merging this PR (and the extractor change) now, with an issue opened for me to go back and fix the IR consistency failures? Or should I try to contribute the necessary IR construction fixes to this PR before we merge it?

@nickrolfe
Copy link
Contributor Author

I made this change in response to the extractor issue you raised, so if it's not a net-positive for IR consistency, I have no issue with postponing the merge.

@dbartol
Copy link
Contributor

dbartol commented Jul 7, 2020

I believe (but have not confirmed) that your change to fix the extractor issue merely breaks the workaround that I was using before. I just have to go back into the IR construction code and change it do do the right thing, rather than the workaround.

@adityasharad adityasharad changed the base branch from master to main August 14, 2020 18:33
@jbj
Copy link
Contributor

jbj commented Sep 18, 2020

Ping @dbartol.

@nickrolfe nickrolfe closed this Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ depends on internal PR This PR should only be merged in sync with an internal Semmle PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants