Skip to content

Commit aa49b35

Browse files
committed
C++: Add an explicit test of DeallocationFunction and DeallocationExpr as well.
1 parent 0cb7d4c commit aa49b35

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

cpp/ql/test/library-tests/allocators/allocators.expected

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,17 @@ allocationExprs
7171
| allocators.cpp:142:13:142:27 | new[] | getSizeExpr = x, getSizeMult = 10, requiresDealloc |
7272
| allocators.cpp:143:13:143:28 | new[] | getSizeBytes = 400, requiresDealloc |
7373
| allocators.cpp:144:13:144:31 | new[] | getSizeExpr = x, getSizeMult = 900, requiresDealloc |
74+
deallocationFunctions
75+
deallocationExprs
76+
| allocators.cpp:59:3:59:35 | delete | getFreedExpr = 0 |
77+
| allocators.cpp:60:3:60:38 | delete | getFreedExpr = 0 |
78+
| allocators.cpp:61:3:61:44 | delete | getFreedExpr = 0 |
79+
| allocators.cpp:62:3:62:43 | delete | getFreedExpr = 0 |
80+
| allocators.cpp:63:3:63:47 | delete | getFreedExpr = 0 |
81+
| allocators.cpp:64:3:64:44 | delete | getFreedExpr = 0 |
82+
| allocators.cpp:78:3:78:37 | delete[] | getFreedExpr = 0 |
83+
| allocators.cpp:79:3:79:40 | delete[] | getFreedExpr = 0 |
84+
| allocators.cpp:80:3:80:46 | delete[] | getFreedExpr = 0 |
85+
| allocators.cpp:81:3:81:45 | delete[] | getFreedExpr = 0 |
86+
| allocators.cpp:82:3:82:49 | delete[] | getFreedExpr = 0 |
87+
| allocators.cpp:83:3:83:23 | delete[] | getFreedExpr = call to GetPointer |

cpp/ql/test/library-tests/allocators/allocators.ql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,19 @@ string describeAllocationExpr(AllocationExpr e) {
139139
query predicate allocationExprs(AllocationExpr e, string descr) {
140140
descr = concat(describeAllocationExpr(e), ", ")
141141
}
142+
143+
string describeDeallocationFunction(DeallocationFunction f) {
144+
result = "getFreedArg = " + f.getFreedArg().toString()
145+
}
146+
147+
query predicate deallocationFunctions(DeallocationFunction f, string descr) {
148+
descr = concat(describeDeallocationFunction(f), ", ")
149+
}
150+
151+
string describeDeallocationExpr(DeallocationExpr e) {
152+
result = "getFreedExpr = " + e.getFreedExpr().toString()
153+
}
154+
155+
query predicate deallocationExprs(DeallocationExpr e, string descr) {
156+
descr = concat(describeDeallocationExpr(e), ", ")
157+
}

0 commit comments

Comments
 (0)