Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8770258

Browse files
C++: Add LambdaExpression.getInitializer()
1 parent d20e5bc commit 8770258

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ class LambdaExpression extends Expr, @lambdaexpr {
5757
Operator getLambdaFunction() {
5858
result = getType().(Closure).getLambdaFunction()
5959
}
60+
61+
/**
62+
* Gets the initializer that initializes the captured variables in the closure, if any.
63+
* A lambda that does not capture any variables will not have an initializer.
64+
*/
65+
Expr getInitializer() {
66+
result = getChild(0)
67+
}
6068
}
6169

6270
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ newtype TTranslatedElement =
270270
throw.getExpr().getFullyConverted() = expr
271271
) or
272272
exists(LambdaExpression lambda |
273-
lambda.getChild(0).getFullyConverted() = expr
273+
lambda.getInitializer().getFullyConverted() = expr
274274
)
275275
)
276276
} or

0 commit comments

Comments
 (0)