-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: Retrieve namespace attributes #19773
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
Conversation
af93668
to
9c2cc35
Compare
9c2cc35
to
09bc57a
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
This PR introduces support for storing and querying attributes on C++ namespaces by adding a new database table and a corresponding QL predicate.
- Add
namespaceattributes
table to the database schema for mapping namespaces to attribute specs - Implement
getAnAttribute
inNamespace.qll
to fetch namespace attributes - Update upgrade/downgrade scripts and change notes to reflect the new feature
Reviewed Changes
Copilot reviewed 5 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
cpp/ql/lib/upgrades/.../upgrade.properties | Add description and backwards compatibility for the new upgrade |
cpp/ql/lib/semmlecode.cpp.dbscheme | Define new namespaceattributes table with refs to namespace and attribute |
cpp/ql/lib/semmle/code/cpp/Namespace.qll | Implement getAnAttribute predicate in the Namespace class |
cpp/ql/lib/change-notes/2025-06-16-namespace-attributes.md | Document the addition of namespace attribute support |
cpp/downgrades/.../upgrade.properties | Add downgrade step to remove namespaceattributes table |
Comments suppressed due to low confidence (2)
cpp/ql/lib/semmle/code/cpp/Namespace.qll:104
- There are no tests covering this new predicate. Consider adding QueryTest cases to verify that
getAnAttribute
correctly retrieves attributes for namespaces under various scenarios.
Attribute getAnAttribute() {
cpp/ql/lib/semmle/code/cpp/Namespace.qll:103
- [nitpick] The doc comment could be more precise about the behavior: does it return all attributes or just one? Also clarify what happens if a namespace has no attributes.
/** Gets an attribute of this namespace. */
|
||
/** Gets an attribute of this namespace. */ | ||
Attribute getAnAttribute() { | ||
namespaceattributes(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.
The predicate call isn’t assigned to the result
variable, so the method won’t return any values. It should read:
result = namespaceattributes(underlyingElement(this), unresolveElement(result));
namespaceattributes(underlyingElement(this), unresolveElement(result)) | |
result = namespaceattributes(underlyingElement(this), unresolveElement(result)) |
Copilot uses AI. Check for mistakes.
Could you add a new test directory to |
I added the tests as you suggested. I noticed that some
|
Looks like that has to do with there being multiple namespace declarations vs just one. |
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.
LGTM.
namespaceattributes
to store namespace attributes.getAnAttribute
toNamespace
to retrieve a namespace attribute.