Skip to content

Commit abd4d39

Browse files
committed
CPP: Examples NameQualifiers.qll.
1 parent 3eec627 commit abd4d39

File tree

1 file changed

+40
-7
lines changed

1 file changed

+40
-7
lines changed

cpp/ql/src/semmle/code/cpp/NameQualifiers.qll

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import cpp
22

33
/**
4-
* A C++ name qualifier, for example `N::`.
4+
* A C++ name qualifier, for example `N::` in the following code:
5+
* ```
6+
* namespace N {
7+
* int f() {
8+
* ...
9+
* }
10+
* }
11+
*
12+
* int g() {
13+
* return N::f();
14+
* }
15+
* ```
516
*/
617
class NameQualifier extends NameQualifiableElement, @namequalifier {
718
/**
@@ -61,10 +72,21 @@ class NameQualifier extends NameQualifiableElement, @namequalifier {
6172

6273
/**
6374
* A C++ element that can be qualified with a name. This is in practice
64-
* either an expression or a name qualifier. For instance, in
65-
* `N1::N2::f()`, there are two name-qualifiable elements: the expression
66-
* `f()` and the name qualifier `N2::`. The former is qualified by `N2` and
67-
* the latter is qualified by `N1`.
75+
* either an expression or a name qualifier. For example, there are two
76+
* name-qualifiable elements in the following code, the expression `f()`
77+
* (which is qualified by `N::`), and the qualifier `N::` (which is not
78+
* itself qualified in this example):
79+
* ```
80+
* namespace N {
81+
* int f() {
82+
* ...
83+
* }
84+
* }
85+
*
86+
* int g() {
87+
* return N::f();
88+
* }
89+
* ```
6890
*/
6991
class NameQualifiableElement extends Element, @namequalifiableelement {
7092
/**
@@ -99,8 +121,19 @@ class NameQualifiableElement extends Element, @namequalifiableelement {
99121
}
100122

101123
/**
102-
* A C++ element that can qualify a name. For example, `N` in `N::f()`. A
103-
* name-qualifying element is either a namespace or a user-defined type.
124+
* A C++ element that can qualify a name. For example, the namespaces `A` and
125+
* `A::B` and the class `A::C` in the following code:
126+
* ```
127+
* namespace A {
128+
* namespace B {
129+
* ...
130+
* }
131+
*
132+
* class C {
133+
* ...
134+
* };
135+
* }
136+
* ```
104137
*/
105138
class NameQualifyingElement extends Element, @namequalifyingelement {
106139
/**

0 commit comments

Comments
 (0)