C++: Test getPlacementArgument().

This commit is contained in:
Geoffrey White
2020-03-31 09:46:21 +01:00
parent 254c877d0a
commit 3b12d1adfd
2 changed files with 5 additions and 2 deletions

View File

@@ -51,8 +51,8 @@ allocationFunctions
| allocators.cpp:8:7:8:20 | operator new[] | getSizeArg = 0, requiresDealloc |
| allocators.cpp:9:7:9:18 | operator new | getSizeArg = 0, requiresDealloc |
| allocators.cpp:10:7:10:20 | operator new[] | getSizeArg = 0, requiresDealloc |
| allocators.cpp:121:7:121:18 | operator new | getSizeArg = 0 |
| allocators.cpp:122:7:122:20 | operator new[] | getSizeArg = 0 |
| allocators.cpp:121:7:121:18 | operator new | getPlacementArgument = 1, getSizeArg = 0 |
| allocators.cpp:122:7:122:20 | operator new[] | getPlacementArgument = 1, getSizeArg = 0 |
| allocators.cpp:123:7:123:18 | operator new | getSizeArg = 0, requiresDealloc |
| allocators.cpp:124:7:124:20 | operator new[] | getSizeArg = 0, requiresDealloc |
| file://:0:0:0:0 | operator new | getSizeArg = 0, requiresDealloc |

View File

@@ -1,4 +1,5 @@
import default
import semmle.code.cpp.models.implementations.Allocation
query predicate newExprs(NewExpr expr, string type, string sig, int size, int alignment, string form, string placement) {
exists(Function allocator, Type allocatedType |
@@ -115,6 +116,8 @@ string describeAllocationFunction(AllocationFunction f) {
f.requiresDealloc() and
result = "requiresDealloc"
)
or
result = "getPlacementArgument = " + f.(OperatorNewAllocationFunction).getPlacementArgument().toString()
}
query predicate allocationFunctions(AllocationFunction f, string descr) {