CPP: QLDoc examples in Struct.qll and Union.qll.

This commit is contained in:
Geoffrey White 2019-08-06 15:36:38 +01:00
Родитель 7e90728c67
Коммит 5d4fba4446
2 изменённых файлов: 61 добавлений и 6 удалений

Просмотреть файл

@ -2,7 +2,18 @@ import semmle.code.cpp.Type
import semmle.code.cpp.Class
/**
* A C/C++ structure or union.
* A C/C++ structure or union. For example, the types `MyStruct` and `MyUnion`
* in:
* ```
* struct MyStruct {
* int x, y, z;
* };
*
* union MyUnion {
* int i;
* float f;
* };
* ```
*/
class Struct extends Class {
@ -16,7 +27,16 @@ class Struct extends Class {
}
/**
* A C++ struct that is directly enclosed by a function.
* A C++ struct that is directly enclosed by a function. For example, the type
* `MyLocalStruct` in:
* ```
* void myFunction()
* {
* struct MyLocalStruct {
* int x, y, z;
* };
* }
* ```
*/
class LocalStruct extends Struct {
LocalStruct() {
@ -28,7 +48,16 @@ class LocalStruct extends Struct {
}
/**
* A C++ nested struct. See 11.12.
* A C++ nested struct. See 11.12. For example, the type `MyNestedStruct` in:
* ```
* class MyClass
* {
* public:
* struct MyNestedStruct {
* int x, y, z;
* };
* };
* ```
*/
class NestedStruct extends Struct {
NestedStruct() {

Просмотреть файл

@ -2,7 +2,13 @@ import semmle.code.cpp.Type
import semmle.code.cpp.Struct
/**
* A C/C++ union. See C.8.2.
* A C/C++ union. See C.8.2. For example, the type `MyUnion` in:
* ```
* union MyUnion {
* int i;
* float f;
* };
* ```
*/
class Union extends Struct {
@ -17,7 +23,17 @@ class Union extends Struct {
}
/**
* A C++ union that is directly enclosed by a function.
* A C++ union that is directly enclosed by a function. For example, the type
* `MyLocalUnion` in:
* ```
* void myFunction()
* {
* union MyLocalUnion {
* int i;
* float f;
* };
* }
* ```
*/
class LocalUnion extends Union {
LocalUnion() {
@ -28,7 +44,17 @@ class LocalUnion extends Union {
}
/**
* A C++ nested union.
* A C++ nested union. For example, the type `MyNestedUnion` in:
* ```
* class MyClass
* {
* public:
* union MyNestedUnion {
* int i;
* float f;
* };
* };
* ```
*/
class NestedUnion extends Union {
NestedUnion() {