@@ -18,7 +18,18 @@ abstract class Access extends Expr, NameQualifiableElement {
18
18
}
19
19
20
20
/**
21
- * A C/C++ enum constant access expression.
21
+ * A C/C++ enum constant access expression. For example the access to
22
+ * `MYENUMCONST1` in `myFunction` in the following code:
23
+ * ```
24
+ * enum MyEnum {
25
+ * MYENUMCONST1,
26
+ * MYENUMCONST2
27
+ * };
28
+ *
29
+ * void myFunction() {
30
+ * MyEnum v = MYENUMCONST1;
31
+ * };
32
+ * ```
22
33
*/
23
34
class EnumConstantAccess extends Access , @varaccess {
24
35
override string getCanonicalQLClass ( ) { result = "EnumConstantAccess" }
@@ -35,7 +46,15 @@ class EnumConstantAccess extends Access, @varaccess {
35
46
}
36
47
37
48
/**
38
- * A C/C++ variable access expression.
49
+ * A C/C++ variable access expression. For example the accesses to
50
+ * `x` and `y` in `myFunction` in the following code:
51
+ * ```
52
+ * int x;
53
+ *
54
+ * void myFunction(int y) {
55
+ * x = y;
56
+ * };
57
+ * ```
39
58
*/
40
59
class VariableAccess extends Access , @varaccess {
41
60
override string getCanonicalQLClass ( ) { result = "VariableAccess" }
@@ -129,7 +148,18 @@ class VariableAccess extends Access, @varaccess {
129
148
}
130
149
131
150
/**
132
- * A C/C++ field access expression.
151
+ * A C/C++ field access expression. For example the accesses to
152
+ * `x` and `y` in `myMethod` in the following code:
153
+ * ```
154
+ * class MyClass {
155
+ * public:
156
+ * void myMethod(MyClass &other) {
157
+ * x = other.y;
158
+ * }
159
+ *
160
+ * int x, y;
161
+ * };
162
+ * ```
133
163
*/
134
164
class FieldAccess extends VariableAccess {
135
165
override string getCanonicalQLClass ( ) { result = "FieldAccess" }
@@ -141,8 +171,20 @@ class FieldAccess extends VariableAccess {
141
171
}
142
172
143
173
/**
144
- * A field access of the form `obj->field`. The type of `obj` is a pointer,
145
- * so this is equivalent to `(*obj).field`.
174
+ * A field access whose qualifier is a pointer to a class, struct or union.
175
+ * These typically take the form `obj->field`, but also includes many accesses
176
+ * with an implicit `this->` qualifier. For example the accesses to `x` and
177
+ * `y` in `myMethod` in the following code:
178
+ * ```
179
+ * class MyClass {
180
+ * public:
181
+ * void myMethod(MyClass *other) {
182
+ other->x = y;
183
+ * }
184
+ *
185
+ * int x, y;
186
+ * };
187
+ * ```
146
188
*/
147
189
class PointerFieldAccess extends FieldAccess {
148
190
override string getCanonicalQLClass ( ) { result = "PointerFieldAccess" }
@@ -169,7 +211,18 @@ class DotFieldAccess extends FieldAccess {
169
211
170
212
/**
171
213
* A field access of the form `obj.field`, where the type of `obj` is a
172
- * reference to a class/struct/union.
214
+ * reference to a class/struct/union. For example the accesses to `y` in
215
+ * `myMethod` in the following code:
216
+ * ```
217
+ * class MyClass {
218
+ * public:
219
+ * void myMethod(MyClass a, MyClass &b) {
220
+ * a.x = b.y;
221
+ * }
222
+ *
223
+ * int x, y;
224
+ * };
225
+ * ```
173
226
*/
174
227
class ReferenceFieldAccess extends DotFieldAccess {
175
228
override string getCanonicalQLClass ( ) { result = "ReferenceFieldAccess" }
@@ -179,7 +232,18 @@ class ReferenceFieldAccess extends DotFieldAccess {
179
232
180
233
/**
181
234
* A field access of the form `obj.field`, where the type of `obj` is a
182
- * class/struct/union (and not a reference).
235
+ * class/struct/union (and not a reference). For example the accesses to `x`
236
+ * in `myMethod` in the following code:
237
+ * ```
238
+ * class MyClass {
239
+ * public:
240
+ * void myMethod(MyClass a, MyClass &b) {
241
+ * a.x = b.y;
242
+ * }
243
+ *
244
+ * int x, y;
245
+ * };
246
+ * ```
183
247
*/
184
248
class ValueFieldAccess extends DotFieldAccess {
185
249
override string getCanonicalQLClass ( ) { result = "ValueFieldAccess" }
@@ -198,20 +262,18 @@ private predicate referenceConversion(Conversion c) {
198
262
/**
199
263
* Holds if `e` is a reference expression (that is, it has a type of the
200
264
* form `T&`), which is converted to a value. For example:
201
- *
202
265
* ```
203
266
* int myfcn(MyStruct &x) {
204
267
* return x.field;
205
268
* }
206
269
* ```
207
- *
208
270
* In this example, the type of `x` is `MyStruct&`, but it gets implicitly
209
271
* converted to `MyStruct` in the expression `x.field`.
210
272
*/
211
273
private predicate exprHasReferenceConversion ( Expr e ) { referenceConversion ( e .getConversion + ( ) ) }
212
274
213
275
/**
214
- * A field access of a field of `this`. The access has no qualifier because
276
+ * A field access of a field of `this` which has no qualifier because
215
277
* the use of `this` is implicit. For example, `field` is equivalent to
216
278
* `this->field` if `field` is a member of `this`.
217
279
*
@@ -250,7 +312,15 @@ class PointerToFieldLiteral extends ImplicitThisFieldAccess {
250
312
}
251
313
252
314
/**
253
- * A C/C++ function access expression.
315
+ * A C/C++ function access expression. For example the access to
316
+ * `myFunctionTarget` in `myFunction` in the following code:
317
+ * ```
318
+ * int myFunctionTarget(int);
319
+ *
320
+ * void myFunction() {
321
+ * int (*myFunctionPointer)(int) = &myTarget;
322
+ * }
323
+ * ```
254
324
*/
255
325
class FunctionAccess extends Access , @routineexpr {
256
326
FunctionAccess ( ) { not iscall ( underlyingElement ( this ) , _) }
@@ -269,7 +339,7 @@ class FunctionAccess extends Access, @routineexpr {
269
339
}
270
340
271
341
/**
272
- * An access to a parameter of a function signature for the purposes of a decltype.
342
+ * An access to a parameter of a function signature for the purposes of a ` decltype` .
273
343
*
274
344
* For example, given the following code:
275
345
* ```
@@ -279,15 +349,30 @@ class FunctionAccess extends Access, @routineexpr {
279
349
* }
280
350
* ```
281
351
* The return type of the function is a decltype, the expression of which contains
282
- * an add expression, which in turn has two ParamAccessForType children.
352
+ * an add expression, which in turn has two ` ParamAccessForType` children.
283
353
*/
284
354
class ParamAccessForType extends Expr , @param_ref {
285
355
override string toString ( ) { result = "param access" }
286
356
}
287
357
288
358
/**
289
359
* An access to a type. This occurs in certain contexts where a built-in
290
- * works on types directly rather than variables, expressions etc.
360
+ * works on types directly rather than variables, expressions etc. For
361
+ * example the reference to `MyClass` in `__is_pod` in the following code:
362
+ * ```
363
+ * class MyClass {
364
+ * ...
365
+ * };
366
+ *
367
+ * void myFunction() {
368
+ * if (__is_pod(MyClass))
369
+ * {
370
+ * ...
371
+ * } else {
372
+ * ...
373
+ * }
374
+ * }
375
+ * ```
291
376
*/
292
377
class TypeName extends Expr , @type_operand {
293
378
override string getCanonicalQLClass ( ) { result = "TypeName" }
@@ -296,24 +381,32 @@ class TypeName extends Expr, @type_operand {
296
381
}
297
382
298
383
/**
299
- * A C/C++ array access expression.
384
+ * A C/C++ array access expression. For example, the access to `as` in
385
+ * `myFunction` in the following code:
386
+ * ```
387
+ * int as[10];
300
388
*
301
- * For calls to operator[], which look syntactically identical, see OverloadedArrayExpr.
389
+ * void myFunction() {
390
+ * as[0]++;
391
+ * }
392
+ * ```
393
+ * For calls to `operator[]`, which look syntactically identical, see
394
+ * `OverloadedArrayExpr`.
302
395
*/
303
396
class ArrayExpr extends Expr , @subscriptexpr {
304
397
override string getCanonicalQLClass ( ) { result = "ArrayExpr" }
305
398
306
399
/**
307
400
* Gets the array or pointer expression being subscripted.
308
401
*
309
- * This is arr in both arr[0] and 0[arr].
402
+ * This is ` arr` in both ` arr[0]` and ` 0[arr]` .
310
403
*/
311
404
Expr getArrayBase ( ) { result = this .getChild ( 0 ) }
312
405
313
406
/**
314
407
* Gets the expression giving the index into the array.
315
408
*
316
- * This is 0 in both arr[0] and 0[arr].
409
+ * This is `0` in both ` arr[0]` and ` 0[arr]` .
317
410
*/
318
411
Expr getArrayOffset ( ) { result = this .getChild ( 1 ) }
319
412
0 commit comments