Skip to content

Commit 0bcee84

Browse files
committed
C++: Minor textual fixes
1 parent 15fe2fb commit 0bcee84

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
description: add `isDesignatorInit`predicate to `ArrayOrVectorAggregateLiteral` and `ClassAggregateLiteral`
1+
description: add `hasDesignator` predicate to `ArrayOrVectorAggregateLiteral` and `ClassAggregateLiteral`
22
compatibility: backwards
33
aggregate_array_init.rel: run aggregate_array_init.qlo
4-
aggregate_field_init.rel: run aggregate_field_init.qlo
4+
aggregate_field_init.rel: run aggregate_field_init.qlo
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
category: feature
33
---
4-
* Introduced `isDesignatorInit()` predicates to distinguish between designator-based and positional initializations for both struct/union fields and array elements.
4+
* Introduced `hasDesignator()` predicates to distinguish between designated and positional initializations for both struct/union fields and array elements.

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

+10-13
Original file line numberDiff line numberDiff line change
@@ -218,20 +218,17 @@ class ClassAggregateLiteral extends AggregateLiteral {
218218

219219
/**
220220
* Holds if the `position`-th initialization of `field` in this aggregate initializer
221-
* uses a designator (e.g., `.x =`, `[42] =`) rather than a positional initializer.
221+
* uses a designated (e.g., `.x = ...`) rather than a positional initializer.
222222
*
223-
* This can be used to distinguish explicitly designated initializations from
224-
* implicit positional ones.
225-
*
226-
* For example, in the initializer:
223+
* For example, in:
227224
* ```c
228225
* struct S { int x, y; };
229226
* struct S s = { .x = 1, 2 };
230227
* ```
231-
* - `.x = 1` is a designator init, therefore `isDesignatorInit(x, 0)` holds.
232-
* - `2` is a positional init for `.y`, therefore `isDesignatorInit(y, 1)` does **not** hold.
228+
* - `.x = 1` is a designated initializer, therefore `hasDesignator(x, 0)` holds.
229+
* - `2` is a positional initializer for `s.y`, therefore `hasDesignator(y, 1)` does not hold.
233230
*/
234-
predicate isDesignatorInit(Field field, int position) {
231+
predicate hasDesignator(Field field, int position) {
235232
field = classType.getAField() and
236233
aggregate_field_init(underlyingElement(this), _, unresolveElement(field), position, true)
237234
}
@@ -330,17 +327,17 @@ class ArrayOrVectorAggregateLiteral extends AggregateLiteral {
330327

331328
/**
332329
* Holds if the `position`-th initialization of the array element at `elementIndex`
333-
* in this aggregate initializer uses a designator (e.g., `[0] = ...`) rather than
334-
* an implicit positional initializer.
330+
* in this aggregate initializer uses a designated (e.g., `[0] = ...`) rather than
331+
* a positional initializer.
335332
*
336333
* For example, in:
337334
* ```c
338335
* int x[] = { [0] = 1, 2 };
339336
* ```
340-
* - `[0] = 1` is a designator init, therefore `isDesignatorInit(0, 0)` holds.
341-
* - `2` is a positional init for `x[1]`, therefore `isDesignatorInit(1, 1)` does **not** hold.
337+
* - `[0] = 1` is a designated initializer, therefore `hasDesignator(0, 0)` holds.
338+
* - `2` is a positional initializer for `x[1]`, therefore `hasDesignator(1, 1)` does not hold.
342339
*/
343-
predicate isDesignatorInit(int elementIndex, int position) {
340+
predicate hasDesignator(int elementIndex, int position) {
344341
aggregate_array_init(underlyingElement(this), _, elementIndex, position, true)
345342
}
346343

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
description: add `isDesignatorInit`predicate to `ArrayOrVectorAggregateLiteral` and `ClassAggregateLiteral`
1+
description: add `hasDesignator` predicate to `ArrayOrVectorAggregateLiteral` and `ClassAggregateLiteral`
22
compatibility: backwards
33
aggregate_array_init.rel: run aggregate_array_init.qlo
4-
aggregate_field_init.rel: run aggregate_field_init.qlo
4+
aggregate_field_init.rel: run aggregate_field_init.qlo

0 commit comments

Comments
 (0)