Skip to content
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

C++: Add missing parent scope cases #17776

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Conversation

jketema
Copy link
Contributor

@jketema jketema commented Oct 15, 2024

This is mostly used to detect the shadowing of variable declarations.

DCA shows no changes. This does break some coding standards tests. I'll update the test results there after this is merged, and open an issue that informs the coding standards people of this. I briefly looked at fixing the query, but (a) it's not clearly documented what the query should do, and (b) this requires digging through about 400 lines of query code, which I find very hard to follow.

Pull Request checklist

All query authors

Internal query authors only

  • Autofixes generated based on these changes are valid, only needed if this PR makes significant changes to .ql, .qll, or .qhelp files. See the documentation (internal access required).
  • Changes are validated at scale (internal access required).
  • Adding a new query? Consider also adding the query to autofix.

@github-actions github-actions bot added the C++ label Oct 15, 2024
@jketema jketema marked this pull request as ready for review October 16, 2024 08:21
@jketema jketema requested a review from a team as a code owner October 16, 2024 08:21
@jketema jketema added the no-change-note-required This PR does not need a change note label Oct 16, 2024
@@ -14,7 +17,11 @@
| 1 | parents.cpp:4:10:4:10 | f | parents.cpp:4:19:13:5 | { ... } |
| 1 | parents.cpp:4:19:13:5 | { ... } | parents.cpp:5:11:5:11 | j |
| 1 | parents.cpp:4:19:13:5 | { ... } | parents.cpp:6:11:10:7 | { ... } |
| 1 | parents.cpp:4:19:13:5 | { ... } | parents.cpp:11:18:11:18 | e |
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like the parent of e should be something associated with the catch block on line 11, rather than the entire function. I can see that this wouldn't fit the current definition of what getParentScope can return. And what you have is probably good enough for what getParentScope is used for.

Copy link
Contributor Author

@jketema jketema Oct 16, 2024

Choose a reason for hiding this comment

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

Yeah, agreed. I struggled a bit with that one initially. What I do now seems to be most in line with all the other cases that are there, and what we want when looking for shadowing.

@geoffw0
Copy link
Contributor

geoffw0 commented Oct 16, 2024

I briefly looked at fixing the query, but (a) it's not clearly documented what the query should do, and (b) this requires digging through about 400 lines of query code, which I find very hard to follow.

Which query is this?

@jketema jketema merged commit bee073d into github:main Oct 16, 2024
14 of 16 checks passed
@jketema jketema deleted the parent-scope branch October 16, 2024 11:12
@geoffw0
Copy link
Contributor

geoffw0 commented Oct 16, 2024

Yep, discussing the intent with one of the authors might help to untangle what's going on there.

@jketema
Copy link
Contributor Author

jketema commented Oct 16, 2024

I've reported the issue on the coding standards repo. I assume they'll have a look once they upgrade to CodeQL 2.19.3 or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants