mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
CPP: Extend the unions test.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
| unions.cpp:4:8:4:12 | Entry | struct | |
|
||||
| unions.cpp:13:7:13:11 | Value | struct | union |
|
||||
| unions.cpp:19:8:19:22 | EntryWithMethod | struct | |
|
||||
| unions.cpp:4:8:4:12 | Entry | Struct |
|
||||
| unions.cpp:13:7:13:11 | Value | Struct, Union |
|
||||
| unions.cpp:19:8:19:22 | EntryWithMethod | Struct |
|
||||
| unions.cpp:27:9:27:20 | MyLocalUnion | LocalUnion, Struct, Union |
|
||||
| unions.cpp:33:7:33:13 | MyClass | |
|
||||
| unions.cpp:36:9:36:21 | MyNestedUnion | NestedUnion, Struct, Union |
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
import cpp
|
||||
|
||||
from Class t, string struct, string union
|
||||
where if t instanceof Struct then struct = "struct" else struct = ""
|
||||
and if t instanceof Union then union = "union" else union = ""
|
||||
select t, struct, union
|
||||
string describe(Class c)
|
||||
{
|
||||
(
|
||||
c instanceof Struct and
|
||||
result = "Struct"
|
||||
) or (
|
||||
c instanceof Union and
|
||||
result = "Union"
|
||||
) or (
|
||||
c instanceof LocalUnion and
|
||||
result = "LocalUnion"
|
||||
) or (
|
||||
c instanceof NestedUnion and
|
||||
result = "NestedUnion"
|
||||
)
|
||||
}
|
||||
|
||||
from Class c
|
||||
select
|
||||
c,
|
||||
concat(describe(c), ", ")
|
||||
|
||||
@@ -21,3 +21,20 @@ struct EntryWithMethod: Entry {
|
||||
return i;
|
||||
}
|
||||
};
|
||||
|
||||
void myFunction()
|
||||
{
|
||||
union MyLocalUnion {
|
||||
int i;
|
||||
float f;
|
||||
};
|
||||
}
|
||||
|
||||
class MyClass
|
||||
{
|
||||
public:
|
||||
union MyNestedUnion {
|
||||
int i;
|
||||
float f;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user