Skip to content

Commit 49bde56

Browse files
committed
C++: Add tests with qualified names in MaD.
1 parent f1cc1e5 commit 49bde56

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

cpp/ql/test/library-tests/dataflow/external-models/flow.ext.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ extensions:
2121
- ["", "", False, "callWithNonTypeTemplate<T>", "(const T &)", "", "Argument[*0]", "ReturnValue", "value", "manual"]
2222
- ["", "TemplateClass1<T>", False, "templateFunction<U>", "(T,U)", "", "Argument[0]", "ReturnValue", "value", "manual"]
2323
- ["", "TemplateClass1", True, "templateFunction2<U,V>", "(U,V)", "", "Argument[1]", "ReturnValue", "value", "manual"]
24-
- ["", "TemplateClass2<T,U>", True, "function", "(U,T)", "", "Argument[1]", "ReturnValue", "value", "manual"]
24+
- ["", "TemplateClass2<T,U>", True, "function", "(U,T)", "", "Argument[1]", "ReturnValue", "value", "manual"]
25+
- ["", "", False, "read_field_from_struct", "", "", "Argument[*0].Field[MyNamespace::MyStructInNamespace::myField]", "ReturnValue", "value", "manual"]
26+
- ["", "", False, "read_field_from_struct_2", "", "", "Argument[*0].Field[MyGlobalStruct::myField]", "ReturnValue", "value", "manual"]

cpp/ql/test/library-tests/dataflow/external-models/sinks.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919
| test.cpp:149:10:149:10 | z | test-sink |
2020
| test.cpp:158:10:158:10 | z | test-sink |
2121
| test.cpp:173:10:173:10 | y | test-sink |
22+
| test.cpp:188:10:188:10 | x | test-sink |
23+
| test.cpp:201:10:201:10 | x | test-sink |

cpp/ql/test/library-tests/dataflow/external-models/sources.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
| test.cpp:146:10:146:18 | call to ymlSource | local |
1414
| test.cpp:155:10:155:18 | call to ymlSource | local |
1515
| test.cpp:170:10:170:18 | call to ymlSource | local |
16+
| test.cpp:186:14:186:22 | call to ymlSource | local |
17+
| test.cpp:199:14:199:22 | call to ymlSource | local |
1618
| windows.cpp:22:15:22:29 | *call to GetCommandLineA | local |
1719
| windows.cpp:34:17:34:38 | *call to GetEnvironmentStringsA | local |
1820
| windows.cpp:39:36:39:38 | GetEnvironmentVariableA output argument | local |

cpp/ql/test/library-tests/dataflow/external-models/test.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,32 @@ void test_class1() {
171171
Class1<int> c;
172172
auto y = c.templateFunction3<unsigned long>(0UL, x);
173173
ymlSink(y); // $ ir
174+
}
175+
176+
namespace MyNamespace {
177+
struct MyStructInNamespace {
178+
int myField;
179+
};
180+
}
181+
182+
int read_field_from_struct(MyNamespace::MyStructInNamespace* s);
183+
184+
void test_fully_qualified_field_test() {
185+
MyNamespace::MyStructInNamespace s;
186+
s.myField = ymlSource();
187+
int x = read_field_from_struct(&s);
188+
ymlSink(x); // $ MISSING: ir
189+
}
190+
191+
struct MyGlobalStruct {
192+
int myField;
193+
};
194+
195+
int read_field_from_struct_2(MyGlobalStruct* s);
196+
197+
void test_fully_qualified_field_test_2() {
198+
MyGlobalStruct s;
199+
s.myField = ymlSource();
200+
int x = read_field_from_struct_2(&s);
201+
ymlSink(x); // $ MISSING: ir
174202
}

0 commit comments

Comments
 (0)