Skip to content

Commit acbca9c

Browse files
committed
C++: Support destroying deletes
1 parent 4c8da54 commit acbca9c

File tree

12 files changed

+9362
-109
lines changed

12 files changed

+9362
-109
lines changed

cpp/downgrades/9629fc87dab7dbed0771bf5ce22bce4d7f943b52/old.dbscheme

Lines changed: 2300 additions & 0 deletions
Large diffs are not rendered by default.

cpp/downgrades/9629fc87dab7dbed0771bf5ce22bce4d7f943b52/semmlecode.cpp.dbscheme

Lines changed: 2296 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
description: Support destroying deletes
2+
compatibility: full
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* A `isDestroyingDeleteDeallocation` predicate was added to the `NewOrNewArrayExpr` and `DeleteOrDeleteArrayExpr` classes to indicate whether the deallocation function is a destroying delete.

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,16 @@ class NewOrNewArrayExpr extends Expr, @any_new_expr {
855855
)
856856
}
857857

858+
/**
859+
* Holds if the deallocation function is a destroying delete.
860+
*/
861+
predicate isDestroyingDeleteDeallocation() {
862+
exists(int form |
863+
expr_deallocator(underlyingElement(this), _, form) and
864+
form.bitAnd(4) != 0 // Bit two is the "destroying delete" bit
865+
)
866+
}
867+
858868
/**
859869
* Gets the type that is being allocated.
860870
*
@@ -1025,6 +1035,16 @@ class DeleteOrDeleteArrayExpr extends Expr, TDeleteOrDeleteArrayExpr {
10251035
)
10261036
}
10271037

1038+
/**
1039+
* Holds if the deallocation function is a destroying delete.
1040+
*/
1041+
predicate isDestroyingDeleteDeallocation() {
1042+
exists(int form |
1043+
expr_deallocator(underlyingElement(this), _, form) and
1044+
form.bitAnd(4) != 0 // Bit two is the "destroying delete" bit
1045+
)
1046+
}
1047+
10281048
/**
10291049
* Gets the object or array being deleted.
10301050
*/

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,8 @@ funbind(
13651365
@assign_expr = @assignexpr | @assign_op_expr | @blockassignexpr
13661366

13671367
/*
1368+
Binary encoding of the allocator form.
1369+
13681370
case @allocator.form of
13691371
0 = plain
13701372
| 1 = alignment
@@ -1383,11 +1385,13 @@ expr_allocator(
13831385
);
13841386

13851387
/*
1388+
Binary encoding of the deallocator form.
1389+
13861390
case @deallocator.form of
13871391
0 = plain
13881392
| 1 = size
13891393
| 2 = alignment
1390-
| 3 = size_and_alignment
1394+
| 4 = destroying_delete
13911395
;
13921396
*/
13931397

0 commit comments

Comments
 (0)