-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: Add support for getting literals in using declarations #19603
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
base: main
Are you sure you want to change the base?
Conversation
ff24105
to
20edf34
Compare
20edf34
to
b322892
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds the ability to retrieve the specific member referenced by a using
declaration in a templated base class and updates toString()
to fall back to this new API.
- Introduces
getReferencedMember()
inUsingDeclarationEntry
. - Modifies
toString()
to usegetDeclaration()
first orgetReferencedMember()
as a fallback. - Documents the feature in a new change-notes entry.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
cpp/ql/lib/semmle/code/cpp/Namespace.qll | Added getReferencedMember() and updated toString() |
cpp/ql/lib/change-notes/2025-05-28-using-template.md | Added feature note for getReferencedMember |
Comments suppressed due to low confidence (2)
cpp/ql/lib/semmle/code/cpp/Namespace.qll:191
- The use of
or
between two assignment statements here is invalid syntax and won't produce the intended fallback behavior. Consider computing both descriptions first or use a conditional expression to assign a singleresult
value.
result = "using " + this.getDeclaration().getDescription() or
cpp/ql/lib/semmle/code/cpp/Namespace.qll:192
getReferencedMember()
returns anElement
, not astring
. You need to call its.getDescription()
(or equivalent) to produce a textual representation.
result = "using " + this.getReferencedMember()
* }; | ||
* ``` | ||
*/ | ||
Element getReferencedMember() { usings(underlyingElement(this), unresolveElement(result), _, _) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could we have a test for this somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I'll do that. Thanks :)
No description provided.