Skip to content

Commit 9190bf2

Browse files
committed
C++: Add example to QLDoc
1 parent a5d4fad commit 9190bf2

File tree

1 file changed

+17
-3
lines changed
  • cpp/ql/lib/semmle/code/cpp/exprs

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,9 +1023,23 @@ class DeleteOrDeleteArrayExpr extends Expr, TDeleteOrDeleteArrayExpr {
10231023
}
10241024

10251025
/**
1026-
* Gets the object or array being deleted, and gets a re-use expression when
1027-
* there is a destructor call and the object is also the qualifier of the
1028-
* call.
1026+
* Gets the object or array being deleted, and gets a `ReuseExpr` when there
1027+
* is a destructor call and the object is also the qualifier of the call.
1028+
*
1029+
* For example, given:
1030+
* ```
1031+
* struct HasDestructor { ~HasDestructor(); };
1032+
* struct PlainOldData { int x, char y; };
1033+
*
1034+
* void f(HasDestructor* hasDestructor, PlainOldData* pod) {
1035+
* delete hasDestructor;
1036+
* delete pod;
1037+
* }
1038+
* ```
1039+
* This predicate yields a `ReuseExpr` for `delete hasDestructor`, as the
1040+
* the deleted expression has a destructor, and that expression is also
1041+
* the qualifier of the destructor call. In the case of `delete pod` the
1042+
* predicate does not yield a `ReuseExpr`, as there is no destructor call.
10291043
*/
10301044
Expr getExprWithReuse() { result = this.getChild(3) }
10311045
}

0 commit comments

Comments
 (0)