Skip to content

Commit a3711e1

Browse files
committed
CPP: Replace getAllocatorCall with getDeallocator call.
1 parent 04f8ed6 commit a3711e1

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

cpp/ql/lib/semmle/code/cpp/PrintAST.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ private predicate namedExprChildPredicates(Expr expr, Element ele, string pred)
826826
or
827827
expr.(Conversion).getExpr() = ele and pred = "getExpr()"
828828
or
829-
expr.(DeleteOrDeleteArrayExpr).getAllocatorCall() = ele and pred = "getAllocatorCall()"
829+
expr.(DeleteOrDeleteArrayExpr).getDeallocatorCall() = ele and pred = "getDeallocatorCall()"
830830
or
831831
expr.(DeleteOrDeleteArrayExpr).getDestructorCall() = ele and pred = "getDestructorCall()"
832832
or

cpp/ql/lib/semmle/code/cpp/controlflow/internal/CFG.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private Node getControlOrderChildSparse(Node n, int i) {
337337
or
338338
i = 1 and result = del.getDestructorCall()
339339
or
340-
i = 2 and result = del.getAllocatorCall()
340+
i = 2 and result = del.getDeallocatorCall()
341341
)
342342
or
343343
n =
@@ -346,7 +346,7 @@ private Node getControlOrderChildSparse(Node n, int i) {
346346
or
347347
i = 1 and result = del.getDestructorCall()
348348
or
349-
i = 2 and result = del.getAllocatorCall()
349+
i = 2 and result = del.getDeallocatorCall()
350350
)
351351
or
352352
n =

cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,13 +963,18 @@ class DeleteOrDeleteArrayExpr extends Expr, TDeleteOrDeleteArrayExpr {
963963
expr_deallocator(underlyingElement(this), unresolveElement(result), _)
964964
}
965965

966+
/**
967+
* DEPRECATED: use `getDeallocatorCall` instead.
968+
*/
969+
deprecated FunctionCall getAllocatorCall() { result = this.getChild(0) }
970+
966971
/**
967972
* Gets the call to a non-default `operator delete` that deallocates storage, if any.
968973
*
969974
* This will only be present when the type being deleted has a custom `operator delete` and
970975
* is not a class with a virtual destructor.
971976
*/
972-
FunctionCall getAllocatorCall() { result = this.getChild(0) }
977+
FunctionCall getDeallocatorCall() { result = this.getChild(0) }
973978

974979
/**
975980
* Holds if the deallocation function expects a size argument.

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ private predicate ignoreExprAndDescendants(Expr expr) {
8484
or
8585
// We do not yet translate destructors properly, so for now we ignore any
8686
// custom deallocator call, if present.
87-
exists(DeleteExpr deleteExpr | deleteExpr.getAllocatorCall() = expr)
87+
exists(DeleteExpr deleteExpr | deleteExpr.getDeallocatorCall() = expr)
8888
or
89-
exists(DeleteArrayExpr deleteArrayExpr | deleteArrayExpr.getAllocatorCall() = expr)
89+
exists(DeleteArrayExpr deleteArrayExpr | deleteArrayExpr.getDeallocatorCall() = expr)
9090
or
9191
exists(BuiltInVarArgsStart vaStartExpr |
9292
vaStartExpr.getLastNamedParameter().getFullyConverted() = expr

cpp/ql/test/library-tests/ir/ir/PrintAST.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8477,7 +8477,7 @@ ir.cpp:
84778477
# 1018| getExpr(): [DeleteExpr] delete
84788478
# 1018| Type = [VoidType] void
84798479
# 1018| ValueCategory = prvalue
8480-
# 1018| getAllocatorCall(): [FunctionCall] call to operator delete
8480+
# 1018| getDeallocatorCall(): [FunctionCall] call to operator delete
84818481
# 1018| Type = [VoidType] void
84828482
# 1018| ValueCategory = prvalue
84838483
# 1018| getExpr(): [Literal] 0
@@ -8555,7 +8555,7 @@ ir.cpp:
85558555
# 1027| getExpr(): [DeleteArrayExpr] delete[]
85568556
# 1027| Type = [VoidType] void
85578557
# 1027| ValueCategory = prvalue
8558-
# 1027| getAllocatorCall(): [FunctionCall] call to operator delete[]
8558+
# 1027| getDeallocatorCall(): [FunctionCall] call to operator delete[]
85598559
# 1027| Type = [VoidType] void
85608560
# 1027| ValueCategory = prvalue
85618561
# 1027| getExpr(): [Literal] 0

0 commit comments

Comments
 (0)