diff --git a/cpp/ql/src/semmle/code/cpp/Struct.qll b/cpp/ql/src/semmle/code/cpp/Struct.qll index ae464c22772..688b9fc6d99 100644 --- a/cpp/ql/src/semmle/code/cpp/Struct.qll +++ b/cpp/ql/src/semmle/code/cpp/Struct.qll @@ -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() { diff --git a/cpp/ql/src/semmle/code/cpp/Union.qll b/cpp/ql/src/semmle/code/cpp/Union.qll index e5c2fd90f12..b4e284768da 100644 --- a/cpp/ql/src/semmle/code/cpp/Union.qll +++ b/cpp/ql/src/semmle/code/cpp/Union.qll @@ -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() {