Skip to content

Use 'getAnElementExpr' instead of 'getElementExpr', and 'getAFieldExpr' instead of 'getFieldExpr'. #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions c/misra/src/codingstandards/c/misra/EssentialTypes.qll
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,12 @@ predicate isAssignmentToEssentialType(Type lValueEssentialType, Expr rValue) {
// Initializing an array
exists(ArrayAggregateLiteral aal |
lValueEssentialType = aal.getElementType() and
rValue = aal.getElementExpr(_)
rValue = aal.getAnElementExpr(_)
)
or
// Initializing a struct or union
exists(ClassAggregateLiteral cal, Field field |
lValueEssentialType = field.getType() and
rValue = cal.getFieldExpr(field)
rValue = cal.getAFieldExpr(field)
)
}
6 changes: 3 additions & 3 deletions cpp/autosar/src/rules/A12-1-5/InitializerHashCons.qll
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ private predicate mk_FieldCons(
analyzableClassAggregateLiteral(cal) and
cal.getUnspecifiedType() = c and
exists(Expr e |
e = cal.getFieldExpr(f).getFullyConverted() and
e = cal.getAFieldExpr(f).getFullyConverted() and
f.getInitializationOrder() = i and
(
hc = hashCons(e) and
Expand All @@ -907,9 +907,9 @@ private predicate mk_FieldCons(
private predicate analyzableClassAggregateLiteral(ClassAggregateLiteral cal) {
forall(int i | exists(cal.getChild(i)) |
strictcount(cal.getChild(i).getFullyConverted()) = 1 and
strictcount(Field f | cal.getChild(i) = cal.getFieldExpr(f)) = 1 and
strictcount(Field f | cal.getChild(i) = cal.getAFieldExpr(f)) = 1 and
strictcount(Field f, int j |
cal.getFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
cal.getAFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
) = 1
)
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/autosar/src/rules/A5-1-9/LambdaEquivalence.qll
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ private module HashCons {
analyzableClassAggregateLiteral(cal) and
cal.getUnspecifiedType() = c and
exists(Expr e |
e = cal.getFieldExpr(f).getFullyConverted() and
e = cal.getAFieldExpr(f).getFullyConverted() and
f.getInitializationOrder() = i and
(
hc = hashConsExpr(e) and
Expand All @@ -1005,9 +1005,9 @@ private module HashCons {
private predicate analyzableClassAggregateLiteral(ClassAggregateLiteral cal) {
forall(int i | exists(cal.getChild(i)) |
strictcount(cal.getChild(i).getFullyConverted()) = 1 and
strictcount(Field f | cal.getChild(i) = cal.getFieldExpr(f)) = 1 and
strictcount(Field f | cal.getChild(i) = cal.getAFieldExpr(f)) = 1 and
strictcount(Field f, int j |
cal.getFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
cal.getAFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
) = 1
)
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/common/src/codingstandards/cpp/StructuralEquivalence.qll
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ private module HashCons {
analyzableClassAggregateLiteral(cal) and
cal.getUnspecifiedType() = c and
exists(Expr e |
e = cal.getFieldExpr(f).getFullyConverted() and
e = cal.getAFieldExpr(f).getFullyConverted() and
f.getInitializationOrder() = i and
(
hc = hashConsExpr(e) and
Expand All @@ -1005,9 +1005,9 @@ private module HashCons {
private predicate analyzableClassAggregateLiteral(ClassAggregateLiteral cal) {
forall(int i | exists(cal.getChild(i)) |
strictcount(cal.getChild(i).getFullyConverted()) = 1 and
strictcount(Field f | cal.getChild(i) = cal.getFieldExpr(f)) = 1 and
strictcount(Field f | cal.getChild(i) = cal.getAFieldExpr(f)) = 1 and
strictcount(Field f, int j |
cal.getFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
cal.getAFieldExpr(f) = cal.getChild(i) and j = f.getInitializationOrder()
) = 1
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module ClassAggregateLiterals {
exists(Expr compilerGeneratedVal, int index, Expr previousExpr |
// Identify the candidate expression which may be compiler generated
compilerGeneratedVal = cal.getChild(index) and
compilerGeneratedVal = cal.getFieldExpr(f) and
compilerGeneratedVal = cal.getAFieldExpr(f) and
// Find the previous expression for this aggregate literal
previousExpr = getPreviousExpr(cal, index)
|
Expand Down Expand Up @@ -201,7 +201,7 @@ class InferredAggregateLiteral extends AggregateLiteral {
predicate isExprValueInitialized(AggregateLiteral al, Expr e) {
// This expression is a value initialized field
exists(Field f |
e = al.(ClassAggregateLiteral).getFieldExpr(f) and
e = al.(ClassAggregateLiteral).getAFieldExpr(f) and
ClassAggregateLiterals::isValueInitialized(al, f)
)
or
Expand Down Expand Up @@ -236,7 +236,7 @@ predicate isLeadingZeroInitialized(AggregateLiteral a) {
// Or because it's a class aggregate, and all other fields are value initialized
forall(Field f |
f = a.getType().(Class).getAField() and
not a.(ClassAggregateLiteral).getFieldExpr(f) = a.getChild(0)
not a.(ClassAggregateLiteral).getAFieldExpr(f) = a.getChild(0)
|
ClassAggregateLiterals::isValueInitialized(a, f)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ query predicate problems(
exists(string parentDescription |
// For class aggergate literal parents, report which field is being assigned to
exists(ClassAggregateLiteral cal, Field field |
cal.getFieldExpr(field) = inferredAggregateLiteral and
cal.getAFieldExpr(field) = inferredAggregateLiteral and
parentDescription = "to field $@" and
explanationElement = field
|
Expand All @@ -37,15 +37,15 @@ query predicate problems(
or
// For array aggregate literal parents, report which index is being assigned to
exists(ArrayAggregateLiteral aal, int elementIndex |
aal.getElementExpr(elementIndex) = inferredAggregateLiteral and
aal.getAnElementExpr(elementIndex) = inferredAggregateLiteral and
parentDescription = "to index " + elementIndex + " in $@" and
explanationElement = aal and
explanationDescription = "array of type " + aal.getType().getName()
)
or
// In some cases, we seem to have missing link, so provide a basic message
not any(ArrayAggregateLiteral aal).getElementExpr(_) = inferredAggregateLiteral and
not any(ClassAggregateLiteral aal).getFieldExpr(_) = inferredAggregateLiteral and
not any(ArrayAggregateLiteral aal).getAnElementExpr(_) = inferredAggregateLiteral and
not any(ClassAggregateLiteral aal).getAFieldExpr(_) = inferredAggregateLiteral and
parentDescription = "to an unnamed field of $@" and
explanationElement = inferredAggregateLiteral.getParent() and
explanationDescription = " " + explanationElement.(Expr).getType().getName()
Expand Down