mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
Merge pull request #19773 from github/idrissrio/namespace-attributes
C++: Retrieve namespace attributes
This commit is contained in:
2499
cpp/downgrades/9baef67d1ffc1551429dbe1c1130815693e28218/old.dbscheme
Normal file
2499
cpp/downgrades/9baef67d1ffc1551429dbe1c1130815693e28218/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
description: Add a predicate `getAnAttribute` to `Namespace`
|
||||
compatibility: full
|
||||
namespaceattributes.rel: delete
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: feature
|
||||
---
|
||||
* Added a predicate `getAnAttribute` to `Namespace` to retrieve a namespace attribute.
|
||||
@@ -99,6 +99,11 @@ class Namespace extends NameQualifyingElement, @namespace {
|
||||
|
||||
/** Gets a file which declares (part of) this namespace. */
|
||||
File getAFile() { result = this.getADeclarationEntry().getLocation().getFile() }
|
||||
|
||||
/** Gets an attribute of this namespace. */
|
||||
Attribute getAnAttribute() {
|
||||
namespaceattributes(underlyingElement(this), unresolveElement(result))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1139,6 +1139,11 @@ varattributes(
|
||||
int spec_id: @attribute ref
|
||||
);
|
||||
|
||||
namespaceattributes(
|
||||
int namespace_id: @namespace ref,
|
||||
int spec_id: @attribute ref
|
||||
);
|
||||
|
||||
stmtattributes(
|
||||
int stmt_id: @stmt ref,
|
||||
int spec_id: @attribute ref
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Add a predicate `getAnAttribute` to `Namespace`
|
||||
compatibility: backwards
|
||||
@@ -0,0 +1,11 @@
|
||||
| file://:0:0:0:0 | MultiSquared | test.cpp:10:13:10:22 | deprecated |
|
||||
| file://:0:0:0:0 | MultiSquared | test.cpp:10:25:10:36 | maybe_unused |
|
||||
| file://:0:0:0:0 | MultiSquared | test.cpp:11:13:11:22 | deprecated |
|
||||
| file://:0:0:0:0 | MultiSquared | test.cpp:11:25:11:36 | maybe_unused |
|
||||
| file://:0:0:0:0 | NamespaceTest | test.cpp:1:26:1:35 | deprecated |
|
||||
| file://:0:0:0:0 | NamespaceTest | test.cpp:2:26:2:35 | deprecated |
|
||||
| file://:0:0:0:0 | NamespaceTest | test.cpp:3:26:3:37 | maybe_unused |
|
||||
| test.cpp:4:53:4:61 | MultiAttr | test.cpp:4:26:4:35 | deprecated |
|
||||
| test.cpp:4:53:4:61 | MultiAttr | test.cpp:4:38:4:49 | maybe_unused |
|
||||
| test.cpp:6:43:6:56 | OuterNamespace::InnerNamespace | test.cpp:6:30:6:39 | deprecated |
|
||||
| test.cpp:9:46:9:61 | NamespaceSquared | test.cpp:9:13:9:22 | deprecated |
|
||||
@@ -0,0 +1,4 @@
|
||||
import cpp
|
||||
|
||||
from Namespace ns
|
||||
select ns, ns.getAnAttribute()
|
||||
11
cpp/ql/test/library-tests/attributes/namespace/test.cpp
Normal file
11
cpp/ql/test/library-tests/attributes/namespace/test.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace __attribute__((deprecated)) NamespaceTest {}
|
||||
namespace __attribute__((deprecated)) NamespaceTest {}
|
||||
namespace __attribute__((maybe_unused)) NamespaceTest {}
|
||||
namespace __attribute__((deprecated, maybe_unused)) MultiAttr {}
|
||||
namespace OuterNamespace {
|
||||
namespace __attribute__((deprecated)) InnerNamespace {}
|
||||
}
|
||||
|
||||
namespace [[deprecated("NamespaceSquared")]] NamespaceSquared {}
|
||||
namespace [[deprecated, maybe_unused]] MultiSquared {}
|
||||
namespace [[deprecated, maybe_unused]] MultiSquared {}
|
||||
Reference in New Issue
Block a user