Skip to content

Commit a889a79

Browse files
committed
CPP: Examples Field.qll.
1 parent f6ccaa5 commit a889a79

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import semmle.code.cpp.Enum
33
import semmle.code.cpp.exprs.Access
44

55
/**
6-
* A C structure member or C++ non-static member variable.
6+
* A C structure member or C++ non-static member variable. For example the
7+
* member variable `m` in the following code (but not `s`):
8+
* ```
9+
* class MyClass {
10+
* public:
11+
* int m;
12+
* static int s;
13+
* };
14+
* ```
715
*/
816
class Field extends MemberVariable {
917

@@ -33,12 +41,13 @@ class Field extends MemberVariable {
3341
/**
3442
* Holds if the field can be initialized as part of an initializer list. For
3543
* example, in:
36-
*
44+
* ```
3745
* struct S {
3846
* unsigned int a : 5;
3947
* unsigned int : 5;
4048
* unsigned int b : 5;
4149
* };
50+
* ```
4251
*
4352
* Fields `a` and `b` are initializable, but the unnamed bitfield is not.
4453
*/
@@ -65,9 +74,13 @@ class Field extends MemberVariable {
6574
}
6675

6776
/**
68-
* A C structure member or C++ member variable declared with an explicit size in bits.
69-
*
70-
* Syntactically, this looks like `int x : 3` in `struct S { int x : 3; };`.
77+
* A C structure member or C++ member variable declared with an explicit size
78+
* in bits. For example the member variable `x` in the following code:
79+
* ```
80+
* struct MyStruct {
81+
* int x : 3;
82+
* };
83+
* ```
7184
*/
7285
class BitField extends Field {
7386
BitField() { bitfield(underlyingElement(this),_,_) }

0 commit comments

Comments
 (0)