CPP: Examples Field.qll.

This commit is contained in:
Geoffrey White
2019-08-19 11:48:58 +01:00
parent f6ccaa5caf
commit a889a79816

View File

@@ -3,7 +3,15 @@ import semmle.code.cpp.Enum
import semmle.code.cpp.exprs.Access
/**
* A C structure member or C++ non-static member variable.
* A C structure member or C++ non-static member variable. For example the
* member variable `m` in the following code (but not `s`):
* ```
* class MyClass {
* public:
* int m;
* static int s;
* };
* ```
*/
class Field extends MemberVariable {
@@ -33,12 +41,13 @@ class Field extends MemberVariable {
/**
* Holds if the field can be initialized as part of an initializer list. For
* example, in:
*
* ```
* struct S {
* unsigned int a : 5;
* unsigned int : 5;
* unsigned int b : 5;
* };
* ```
*
* Fields `a` and `b` are initializable, but the unnamed bitfield is not.
*/
@@ -65,9 +74,13 @@ class Field extends MemberVariable {
}
/**
* A C structure member or C++ member variable declared with an explicit size in bits.
*
* Syntactically, this looks like `int x : 3` in `struct S { int x : 3; };`.
* A C structure member or C++ member variable declared with an explicit size
* in bits. For example the member variable `x` in the following code:
* ```
* struct MyStruct {
* int x : 3;
* };
* ```
*/
class BitField extends Field {
BitField() { bitfield(underlyingElement(this),_,_) }