Skip to content

Commit 5a4efab

Browse files
committed
C++: Add tests for shared_ptr.
1 parent 8dc7b64 commit 5a4efab

File tree

1 file changed

+18
-0
lines changed
  • cpp/ql/test/library-tests/dataflow/smart-pointers-taint

1 file changed

+18
-0
lines changed

cpp/ql/test/library-tests/dataflow/smart-pointers-taint/test.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,22 @@ void test_unique_ptr_struct() {
2525
sink(p1->y);
2626
sink(p2->x); // $ ir=22:46
2727
sink(p2->y); // $ SPURIOUS: ir=22:46
28+
}
29+
30+
void test_shared_ptr_int() {
31+
std::shared_ptr<int> p1(new int(source()));
32+
std::shared_ptr<int> p2 = std::make_shared<int>(source());
33+
34+
sink(*p1); // $ ast
35+
sink(*p2); // $ ast ir=32:50
36+
}
37+
38+
void test_shared_ptr_struct() {
39+
std::shared_ptr<A> p1(new A{source(), 0});
40+
std::shared_ptr<A> p2 = std::make_shared<A>(source(), 0);
41+
42+
sink(p1->x); // $ MISSING: ast,ir
43+
sink(p1->y);
44+
sink(p2->x); // $ ir=40:46
45+
sink(p2->y); // $ SPURIOUS: ir=40:46
2846
}

0 commit comments

Comments
 (0)