Conversation
af93668 to
9c2cc35
Compare
9c2cc35 to
09bc57a
Compare
There was a problem hiding this comment.
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
namespaceattributestable to the database schema for mapping namespaces to attribute specs - Implement
getAnAttributeinNamespace.qllto 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
getAnAttributecorrectly 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.
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)) |
|
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. |
namespaceattributesto store namespace attributes.getAnAttributetoNamespaceto retrieve a namespace attribute.