Skip to content

Commit cd8ea67

Browse files
committed
EssentialType: Reduce duplication in conditional calc
Avoid repeating code for both the signed and unsigned cases.
1 parent 62da9c8 commit cd8ea67

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,21 +267,13 @@ class EssentialConditionalExpr extends EssentialExpr, ConditionalExpr {
267267
then result = thenEssentialType
268268
else
269269
if
270-
getEssentialTypeCategory(thenEssentialType) = EssentiallySignedType() and
271-
getEssentialTypeCategory(elseEssentialType) = EssentiallySignedType()
270+
getEssentialTypeCategory(thenEssentialType) = getEssentialTypeCategory(elseEssentialType) and
271+
getEssentialTypeCategory(thenEssentialType) instanceof EssentiallySignedOrUnsignedType
272272
then
273273
if thenEssentialType.getSize() > elseEssentialType.getSize()
274274
then result = thenEssentialType
275275
else result = elseEssentialType
276-
else
277-
if
278-
getEssentialTypeCategory(thenEssentialType) = EssentiallyUnsignedType() and
279-
getEssentialTypeCategory(elseEssentialType) = EssentiallyUnsignedType()
280-
then
281-
if thenEssentialType.getSize() > elseEssentialType.getSize()
282-
then result = thenEssentialType
283-
else result = elseEssentialType
284-
else result = this.getStandardType()
276+
else result = this.getStandardType()
285277
)
286278
}
287279
}

0 commit comments

Comments
 (0)