Skip to content

Commit a702f7a

Browse files
authored
Merge pull request #19773 from github/idrissrio/namespace-attributes
C++: Retrieve namespace attributes
2 parents e1b9d9f + 9fb47cc commit a702f7a

File tree

13 files changed

+14881
-4552
lines changed

13 files changed

+14881
-4552
lines changed

cpp/downgrades/9baef67d1ffc1551429dbe1c1130815693e28218/old.dbscheme

Lines changed: 2499 additions & 0 deletions
Large diffs are not rendered by default.

cpp/downgrades/9baef67d1ffc1551429dbe1c1130815693e28218/semmlecode.cpp.dbscheme

Lines changed: 2494 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: Add a predicate `getAnAttribute` to `Namespace`
2+
compatibility: full
3+
namespaceattributes.rel: delete
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Added a predicate `getAnAttribute` to `Namespace` to retrieve a namespace attribute.

cpp/ql/lib/semmle/code/cpp/Namespace.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ class Namespace extends NameQualifyingElement, @namespace {
9999

100100
/** Gets a file which declares (part of) this namespace. */
101101
File getAFile() { result = this.getADeclarationEntry().getLocation().getFile() }
102+
103+
/** Gets an attribute of this namespace. */
104+
Attribute getAnAttribute() {
105+
namespaceattributes(underlyingElement(this), unresolveElement(result))
106+
}
102107
}
103108

104109
/**

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,11 @@ varattributes(
11391139
int spec_id: @attribute ref
11401140
);
11411141

1142+
namespaceattributes(
1143+
int namespace_id: @namespace ref,
1144+
int spec_id: @attribute ref
1145+
);
1146+
11421147
stmtattributes(
11431148
int stmt_id: @stmt ref,
11441149
int spec_id: @attribute ref

0 commit comments

Comments
 (0)