Skip to content

Commit 6dd6488

Browse files
committed
C++: Introduce 'getAnElementExpr' and 'getAnExpr'.
1 parent ea180c0 commit 6dd6488

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,22 @@ class ClassAggregateLiteral extends AggregateLiteral {
187187
override string getAPrimaryQlClass() { result = "ClassAggregateLiteral" }
188188

189189
/**
190+
* Gets an expression within the aggregate literal that is used to initialize
191+
* field `field`, if present.
192+
*
193+
* This predicate may have multiple results since a field can be initialized
194+
* multiple times in the same initializer.
195+
*/
196+
Expr getAFieldExpr(Field field) { result = this.getFieldExpr(field, _) }
197+
198+
/**
199+
* DEPRECATED: Use `getAFieldExpr` instead.
200+
*
190201
* Gets the expression within the aggregate literal that is used to initialize
191202
* field `field`, if present.
203+
*
204+
* This predicate may have multiple results since a field can be initialized
205+
* multiple times in the same initializer.
192206
*/
193207
Expr getFieldExpr(Field field) { result = this.getFieldExpr(field, _) }
194208

@@ -274,8 +288,22 @@ class ArrayOrVectorAggregateLiteral extends AggregateLiteral {
274288
Type getElementType() { none() }
275289

276290
/**
291+
* Gets an expression within the aggregate literal that is used to initialize
292+
* element `elementIndex`, if present.
293+
*
294+
* This predicate may have multiple results since an element can be initialized
295+
* multiple times in the same initializer.
296+
*/
297+
Expr getAnElementExpr(int elementIndex) { result = this.getElementExpr(elementIndex, _) }
298+
299+
/**
300+
* DEPRECATED: Use `getAnElementExpr` instead.
301+
*
277302
* Gets the expression within the aggregate literal that is used to initialize
278303
* element `elementIndex`, if present.
304+
*
305+
* This predicate may have multiple results since an element can be initialized
306+
* multiple times in the same initializer.
279307
*/
280308
Expr getElementExpr(int elementIndex) { result = this.getElementExpr(elementIndex, _) }
281309

0 commit comments

Comments
 (0)