mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
C++: Add a way to test the behavior of 'asExpr' and 'toString' on dataflow nodes.
This commit is contained in:
23
cpp/ql/test/library-tests/dataflow/asExpr/test.cpp
Normal file
23
cpp/ql/test/library-tests/dataflow/asExpr/test.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
void take_const_ref_int(const int &);
|
||||
|
||||
void test_materialize_temp_int()
|
||||
{
|
||||
take_const_ref_int(42); // $ asExpr=42 numberOfNodes="42: 2" asIndirectExpr=42 numberOfIndirectNodes="42: 2"
|
||||
}
|
||||
|
||||
struct A {};
|
||||
|
||||
A get();
|
||||
void take_const_ref(const A &);
|
||||
|
||||
void test1(){
|
||||
take_const_ref(get()); // $ asExpr="call to get" numberOfNodes="call to get: 2" asIndirectExpr="call to get" numberOfIndirectNodes="call to get: 2"
|
||||
}
|
||||
|
||||
void take_ref(A &);
|
||||
|
||||
A& get_ref();
|
||||
|
||||
void test2() {
|
||||
take_ref(get_ref()); // $ asExpr="call to get_ref" asIndirectExpr="call to get_ref"
|
||||
}
|
||||
Reference in New Issue
Block a user