Skip to content

C++: Work around two false positive issues with the UnusedLocals.ql query #4592

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

Merged
merged 7 commits into from
Nov 13, 2020

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Nov 2, 2020

Test cases and workaround fixes for the issues highlighted by #4569 and #4570.

Sample of results from LGTM that will now be excluded: https://lgtm.com/query/6496877322277687392/


@igfoo I believe both cases may be caused by limitations in the extractor where a variable is accessed in a particular context, but no VariableAccess in generated.

  • on line 143 of the test; the expression on the left side of the ; (a ConditionDeclExpr) appears not to have been extracted correctly. If this is fixed I would like to remove the exclusion for ConditionDeclExpr from this query (affects up to ~0.2% of functions).
  • on line 164 of the test; ideally there would be a VariableAccess inside the expression that is currently an 'unknown literal', so we don't need to exclude all functions containing unknown literals from the test (affects up to ~10% of functions).

Are you happy to deal with these, should I create issues, or are they already on your radar?

@igfoo
Copy link
Contributor

igfoo commented Nov 5, 2020

I had a quick look at the first one, and I can't immediately see what's going wrong. Could you file a couple of tickets please? Thanks!

Comment on lines 61 to 65
not exists(Literal l |
l.getEnclosingFunction() = f and
not exists(l.getValue())
) and
not any(ConditionDeclExpr cde).getEnclosingFunction() = f
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some comments that'll help us know when to delete these extra conditions in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. The details aren't really fresh in my mind any more, but at least its documented that they should at some point be removed.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Nov 11, 2020

Could you file a couple of tickets please?

Done: https://github.com/github/codeql-c-extractor-team/issues/150 and https://github.com/github/codeql-c-extractor-team/issues/151.

It's a while since I looked at this so apologies for any inaccuracies - particularly on the second one.

@jbj
Copy link
Contributor

jbj commented Nov 12, 2020

The qlformat test failed

@geoffw0
Copy link
Contributor Author

geoffw0 commented Nov 12, 2020

Thanks, fixed.

@jbj jbj merged commit 8bb9e8a into github:main Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants