Skip to content

Commit 3b12d1a

Browse files
committed
C++: Test getPlacementArgument().
1 parent 254c877 commit 3b12d1a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ allocationFunctions
5151
| allocators.cpp:8:7:8:20 | operator new[] | getSizeArg = 0, requiresDealloc |
5252
| allocators.cpp:9:7:9:18 | operator new | getSizeArg = 0, requiresDealloc |
5353
| allocators.cpp:10:7:10:20 | operator new[] | getSizeArg = 0, requiresDealloc |
54-
| allocators.cpp:121:7:121:18 | operator new | getSizeArg = 0 |
55-
| allocators.cpp:122:7:122:20 | operator new[] | getSizeArg = 0 |
54+
| allocators.cpp:121:7:121:18 | operator new | getPlacementArgument = 1, getSizeArg = 0 |
55+
| allocators.cpp:122:7:122:20 | operator new[] | getPlacementArgument = 1, getSizeArg = 0 |
5656
| allocators.cpp:123:7:123:18 | operator new | getSizeArg = 0, requiresDealloc |
5757
| allocators.cpp:124:7:124:20 | operator new[] | getSizeArg = 0, requiresDealloc |
5858
| file://:0:0:0:0 | operator new | getSizeArg = 0, requiresDealloc |

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import default
2+
import semmle.code.cpp.models.implementations.Allocation
23

34
query predicate newExprs(NewExpr expr, string type, string sig, int size, int alignment, string form, string placement) {
45
exists(Function allocator, Type allocatedType |
@@ -115,6 +116,8 @@ string describeAllocationFunction(AllocationFunction f) {
115116
f.requiresDealloc() and
116117
result = "requiresDealloc"
117118
)
119+
or
120+
result = "getPlacementArgument = " + f.(OperatorNewAllocationFunction).getPlacementArgument().toString()
118121
}
119122

120123
query predicate allocationFunctions(AllocationFunction f, string descr) {

0 commit comments

Comments
 (0)