Skip to content

Commit f9a808a

Browse files
committed
Rule 13.2: Further perf improvements
Extract out the main computation from the exclusion mechanism, otherwise the exclusion mechanism runs on a potentially very large intermediate step (sameFullExpr).
1 parent 3de4838 commit f9a808a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

c/misra/src/rules/RULE-13-2/UnsequencedSideEffects.ql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,10 @@ predicate inConditionalElse(ConditionalExpr ce, Expr e) {
172172
)
173173
}
174174

175-
from
175+
predicate isUnsequencedEffect(
176176
ConstituentExprOrdering orderingConfig, FullExpr fullExpr, VariableEffect variableEffect1,
177177
VariableAccess va1, VariableAccess va2, Locatable placeHolder, string label
178-
where
179-
not isExcluded(fullExpr, SideEffects3Package::unsequencedSideEffectsQuery()) and
178+
) {
180179
// The two access are scoped to the same full expression.
181180
sameFullExpr(fullExpr, va1, va2) and
182181
// We are only interested in effects that change an object,
@@ -238,5 +237,13 @@ where
238237
) and
239238
// Both are evaluated
240239
not exists(ConditionalExpr ce | inConditionalThen(ce, va1) and inConditionalElse(ce, va2))
240+
}
241+
242+
from
243+
ConstituentExprOrdering orderingConfig, FullExpr fullExpr, VariableEffect variableEffect1,
244+
VariableAccess va1, VariableAccess va2, Locatable placeHolder, string label
245+
where
246+
not isExcluded(fullExpr, SideEffects3Package::unsequencedSideEffectsQuery()) and
247+
isUnsequencedEffect(orderingConfig, fullExpr, variableEffect1, va1, va2, placeHolder, label)
241248
select fullExpr, "The expression contains unsequenced $@ to $@ and $@ to $@.", variableEffect1,
242249
"side effect", va1, va1.getTarget().getName(), placeHolder, label, va2, va2.getTarget().getName()

0 commit comments

Comments
 (0)