Skip to content

Commit f573c71

Browse files
authored
Merge pull request #291 from jketema/add-a
Use 'getAnElementExpr' instead of 'getElementExpr', and 'getAFieldExpr' instead of 'getFieldExpr'.
2 parents 260897d + d5ca95b commit f573c71

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

c/misra/src/codingstandards/c/misra/EssentialTypes.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ predicate isAssignmentToEssentialType(Type lValueEssentialType, Expr rValue) {
365365
// Initializing an array
366366
exists(ArrayAggregateLiteral aal |
367367
lValueEssentialType = aal.getElementType() and
368-
rValue = aal.getElementExpr(_)
368+
rValue = aal.getAnElementExpr(_)
369369
)
370370
or
371371
// Initializing a struct or union
372372
exists(ClassAggregateLiteral cal, Field field |
373373
lValueEssentialType = field.getType() and
374-
rValue = cal.getFieldExpr(field)
374+
rValue = cal.getAFieldExpr(field)
375375
)
376376
}

cpp/autosar/src/rules/A12-1-5/InitializerHashCons.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ private predicate mk_FieldCons(
891891
analyzableClassAggregateLiteral(cal) and
892892
cal.getUnspecifiedType() = c and
893893
exists(Expr e |
894-
e = cal.getFieldExpr(f).getFullyConverted() and
894+
e = cal.getAFieldExpr(f).getFullyConverted() and
895895
f.getInitializationOrder() = i and
896896
(
897897
hc = hashCons(e) and
@@ -907,9 +907,9 @@ private predicate mk_FieldCons(
907907
private predicate analyzableClassAggregateLiteral(ClassAggregateLiteral cal) {
908908
forall(int i | exists(cal.getChild(i)) |
909909
strictcount(cal.getChild(i).getFullyConverted()) = 1 and
910-
strictcount(Field f | cal.getChild(i) = cal.getFieldExpr(f)) = 1 and
910+
strictcount(Field f | cal.getChild(i) = cal.getAFieldExpr(f)) = 1 and
911911
strictcount(Field f, int j |
912-
cal.getFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
912+
cal.getAFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
913913
) = 1
914914
)
915915
}

cpp/autosar/src/rules/A5-1-9/LambdaEquivalence.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ private module HashCons {
989989
analyzableClassAggregateLiteral(cal) and
990990
cal.getUnspecifiedType() = c and
991991
exists(Expr e |
992-
e = cal.getFieldExpr(f).getFullyConverted() and
992+
e = cal.getAFieldExpr(f).getFullyConverted() and
993993
f.getInitializationOrder() = i and
994994
(
995995
hc = hashConsExpr(e) and
@@ -1005,9 +1005,9 @@ private module HashCons {
10051005
private predicate analyzableClassAggregateLiteral(ClassAggregateLiteral cal) {
10061006
forall(int i | exists(cal.getChild(i)) |
10071007
strictcount(cal.getChild(i).getFullyConverted()) = 1 and
1008-
strictcount(Field f | cal.getChild(i) = cal.getFieldExpr(f)) = 1 and
1008+
strictcount(Field f | cal.getChild(i) = cal.getAFieldExpr(f)) = 1 and
10091009
strictcount(Field f, int j |
1010-
cal.getFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
1010+
cal.getAFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
10111011
) = 1
10121012
)
10131013
}

cpp/common/src/codingstandards/cpp/StructuralEquivalence.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ private module HashCons {
989989
analyzableClassAggregateLiteral(cal) and
990990
cal.getUnspecifiedType() = c and
991991
exists(Expr e |
992-
e = cal.getFieldExpr(f).getFullyConverted() and
992+
e = cal.getAFieldExpr(f).getFullyConverted() and
993993
f.getInitializationOrder() = i and
994994
(
995995
hc = hashConsExpr(e) and
@@ -1005,9 +1005,9 @@ private module HashCons {
10051005
private predicate analyzableClassAggregateLiteral(ClassAggregateLiteral cal) {
10061006
forall(int i | exists(cal.getChild(i)) |
10071007
strictcount(cal.getChild(i).getFullyConverted()) = 1 and
1008-
strictcount(Field f | cal.getChild(i) = cal.getFieldExpr(f)) = 1 and
1008+
strictcount(Field f | cal.getChild(i) = cal.getAFieldExpr(f)) = 1 and
10091009
strictcount(Field f, int j |
1010-
cal.getFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
1010+
cal.getAFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
10111011
) = 1
10121012
)
10131013
}

cpp/common/src/codingstandards/cpp/enhancements/AggregateLiteralEnhancements.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ module ClassAggregateLiterals {
114114
exists(Expr compilerGeneratedVal, int index, Expr previousExpr |
115115
// Identify the candidate expression which may be compiler generated
116116
compilerGeneratedVal = cal.getChild(index) and
117-
compilerGeneratedVal = cal.getFieldExpr(f) and
117+
compilerGeneratedVal = cal.getAFieldExpr(f) and
118118
// Find the previous expression for this aggregate literal
119119
previousExpr = getPreviousExpr(cal, index)
120120
|
@@ -201,7 +201,7 @@ class InferredAggregateLiteral extends AggregateLiteral {
201201
predicate isExprValueInitialized(AggregateLiteral al, Expr e) {
202202
// This expression is a value initialized field
203203
exists(Field f |
204-
e = al.(ClassAggregateLiteral).getFieldExpr(f) and
204+
e = al.(ClassAggregateLiteral).getAFieldExpr(f) and
205205
ClassAggregateLiterals::isValueInitialized(al, f)
206206
)
207207
or
@@ -236,7 +236,7 @@ predicate isLeadingZeroInitialized(AggregateLiteral a) {
236236
// Or because it's a class aggregate, and all other fields are value initialized
237237
forall(Field f |
238238
f = a.getType().(Class).getAField() and
239-
not a.(ClassAggregateLiteral).getFieldExpr(f) = a.getChild(0)
239+
not a.(ClassAggregateLiteral).getAFieldExpr(f) = a.getChild(0)
240240
|
241241
ClassAggregateLiterals::isValueInitialized(a, f)
242242
)

cpp/common/src/codingstandards/cpp/rules/useinitializerbracestomatchaggregatetypestructure/UseInitializerBracesToMatchAggregateTypeStructure.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ query predicate problems(
2828
exists(string parentDescription |
2929
// For class aggergate literal parents, report which field is being assigned to
3030
exists(ClassAggregateLiteral cal, Field field |
31-
cal.getFieldExpr(field) = inferredAggregateLiteral and
31+
cal.getAFieldExpr(field) = inferredAggregateLiteral and
3232
parentDescription = "to field $@" and
3333
explanationElement = field
3434
|
@@ -37,15 +37,15 @@ query predicate problems(
3737
or
3838
// For array aggregate literal parents, report which index is being assigned to
3939
exists(ArrayAggregateLiteral aal, int elementIndex |
40-
aal.getElementExpr(elementIndex) = inferredAggregateLiteral and
40+
aal.getAnElementExpr(elementIndex) = inferredAggregateLiteral and
4141
parentDescription = "to index " + elementIndex + " in $@" and
4242
explanationElement = aal and
4343
explanationDescription = "array of type " + aal.getType().getName()
4444
)
4545
or
4646
// In some cases, we seem to have missing link, so provide a basic message
47-
not any(ArrayAggregateLiteral aal).getElementExpr(_) = inferredAggregateLiteral and
48-
not any(ClassAggregateLiteral aal).getFieldExpr(_) = inferredAggregateLiteral and
47+
not any(ArrayAggregateLiteral aal).getAnElementExpr(_) = inferredAggregateLiteral and
48+
not any(ClassAggregateLiteral aal).getAFieldExpr(_) = inferredAggregateLiteral and
4949
parentDescription = "to an unnamed field of $@" and
5050
explanationElement = inferredAggregateLiteral.getParent() and
5151
explanationDescription = " " + explanationElement.(Expr).getType().getName()

0 commit comments

Comments
 (0)