C++: inline arithTypesMatch predicate #3316
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WAIT: I'm starting to wonder whether this bug is real or whether it was just my laptop that froze up for 170 seconds. I wasn't at the keyboard at the time. I'll repeat the experiment tonight and only take this PR out of draft if the problem reproduces.This predicate is effectively a Cartesian product between all enum types. It's infeasible to compute it in full, so luckily the optimizer has been able to apply enough magic to make it feasible. That's not a robust solution, and it has indeed broken on at least one version of the 1.24 release candidate.
On a Chromium snapshot where I ran the LGTM suite overnight, the
m#MistypedFunctionArguments::arithTypesMatch#bb
predicate (magic forarithTypesMatch
) took 170m5s. That was commit b69fdf5 from the internal repo. I tried to reproduce it in VSCode, this time with commit 646646, but it wasn't quite as bad: the predicate took only 38 seconds. In any case, making the problematic predicatepragma[inline]
removes the slow magic and makes theMistypedFunctionArguments.ql
query faster.