Skip to content

Commit bc3e4e4

Browse files
committed
CPP: Examples Lambda.qll.
1 parent d29eefd commit bc3e4e4

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

cpp/ql/src/semmle/code/cpp/exprs/Lambda.qll

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import semmle.code.cpp.exprs.Expr
22
import semmle.code.cpp.Class
33

44
/**
5-
* A C++11 lambda expression, such as `[&, =y](int x) mutable -> double {return z = (y += x);}`.
5+
* A C++11 lambda expression, for example the expression initializing `a` in
6+
* the following code:
7+
* ```
8+
* auto a = [x, y](int z) -> int {
9+
* return x + y + z;
10+
* };
11+
* ```
612
*
713
* The type given by `getType()` will be an instance of `Closure`.
814
*/
@@ -71,6 +77,12 @@ class LambdaExpression extends Expr, @lambdaexpr {
7177

7278
/**
7379
* A class written by the compiler to be the type of a C++11 lambda expression.
80+
* For example the variable `a` in the following code has a closure type:
81+
* ```
82+
* auto a = [x, y](int z) -> int {
83+
* return x + y + z;
84+
* };
85+
* ```
7486
*/
7587
class Closure extends Class {
7688
Closure() {
@@ -96,7 +108,13 @@ class Closure extends Class {
96108
}
97109

98110
/**
99-
* Information about a value captured as part of a lambda expression.
111+
* Information about a value captured as part of a lambda expression. For
112+
* example in the following code, information about `x` and `y` is captured:
113+
* ```
114+
* auto a = [x, y](int z) -> int {
115+
* return x + y + z;
116+
* };
117+
* ```
100118
*/
101119
class LambdaCapture extends @lambdacapture {
102120
string toString() {

0 commit comments

Comments
 (0)