Skip to content

Commit 8f90917

Browse files
committed
MSC39-C: Hint optimizer to join isExcluded after determining results
1 parent dfdfe9b commit 8f90917

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

c/cert/src/rules/MSC39-C/DoNotCallVaArgOnAVaListThatHasAnIndeterminateValue.ql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,19 @@ predicate sameSource(VaAccess e1, VaAccess e2) {
7171
)
7272
}
7373

74+
/**
75+
* Extracted to avoid poor magic join ordering on the `isExcluded` predicate.
76+
*/
77+
predicate query(VaAccess va_acc, VaArgArg va_arg, FunctionCall fc) {
78+
sameSource(va_acc, va_arg) and
79+
fc = preceedsFC(va_acc) and
80+
fc.getTarget().calls*(va_arg.getEnclosingFunction())
81+
}
82+
7483
from VaAccess va_acc, VaArgArg va_arg, FunctionCall fc
7584
where
7685
not isExcluded(va_acc,
7786
Contracts7Package::doNotCallVaArgOnAVaListThatHasAnIndeterminateValueQuery()) and
78-
sameSource(va_acc, va_arg) and
79-
fc = preceedsFC(va_acc) and
80-
fc.getTarget().calls*(va_arg.getEnclosingFunction())
87+
query(va_acc, va_arg, fc)
8188
select va_acc, "The value of " + va_acc.toString() + " is indeterminate after the $@.", fc,
8289
fc.toString()

0 commit comments

Comments
 (0)