C++: Fix isCompiledAsC join order#21699
Merged
jketema merged 1 commit intogithub:mainfrom Apr 13, 2026
Merged
Conversation
Before on Abseil Windows for `cpp/too-few-arguments:`:
```
Pipeline standard for TooFewArguments::isCompiledAsC/1#52fe29e8@994f9bgp was evaluated in 12 iterations totaling 2ms (delta sizes total: 50).
1198778 ~3% {1} r1 = JOIN `TooFewArguments::isCompiledAsC/1#52fe29e8#prev_delta` WITH `Element::Element.getFile/0#2b8c8740_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1
83 ~26% {1} | JOIN WITH includes ON FIRST 1 OUTPUT Rhs.1
50 ~4% {1} | AND NOT `TooFewArguments::isCompiledAsC/1#52fe29e8#prev`(FIRST 1)
return r1
```
After:
```
Pipeline standard for #File::File.getAnIncludedFile/0#dispred#e8d44cd1Plus#bf@b8d290i6 was evaluated in 11 iterations totaling 0ms (delta sizes total: 43).
47 ~0% {2} r1 = SCAN `#File::File.getAnIncludedFile/0#dispred#e8d44cd1Plus#bf#prev_delta` OUTPUT In.1, In.0
78 ~28% {2} | JOIN WITH `File::File.getAnIncludedFile/0#dispred#e8d44cd1` ON FIRST 1 OUTPUT Lhs.1, Rhs.1
43 ~0% {2} | AND NOT `#File::File.getAnIncludedFile/0#dispred#e8d44cd1Plus#bf#prev`(FIRST 2)
return r1
[2026-04-13 11:05:25] Evaluated non-recursive predicate TooFewArguments::isCompiledAsC/1#52fe29e8@4a3eb9jk in 0ms (size: 49).
Evaluated relational algebra for predicate TooFewArguments::isCompiledAsC/1#52fe29e8@4a3eb9jk with tuple counts:
1 ~0% {3} r1 = CONSTANT(unique int, unique string, unique string)[1,"compiled as c","1"]
1 ~0% {1} | JOIN WITH #fileannotationsMerge_1230#join_rhs ON FIRST 3 OUTPUT Rhs.3
48 ~0% {1} r2 = JOIN r1 WITH `#File::File.getAnIncludedFile/0#dispred#e8d44cd1Plus#bf` ON FIRST 1 OUTPUT Rhs.1
49 ~0% {1} r3 = r1 UNION r2
return r3
```
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the C++ “Underspecified Functions” query libraries to improve evaluation performance by rewriting the isCompiledAsC predicate in a way that yields a better join order in CodeQL’s relational evaluation, as observed in nightly experiments.
Changes:
- Rewrites
isCompiledAsC(File)to usegetAnIncludedFile*()instead of explicit recursion. - Applies the same predicate rewrite consistently across the “Too many arguments”, “Too few arguments”, and “Mistyped function arguments” libraries.
Show a summary per file
| File | Description |
|---|---|
| cpp/ql/src/Likely Bugs/Underspecified Functions/TooManyArguments.qll | Rewrites isCompiledAsC to use transitive include closure for improved join order. |
| cpp/ql/src/Likely Bugs/Underspecified Functions/TooFewArguments.qll | Same isCompiledAsC rewrite to improve evaluation performance and consistency. |
| cpp/ql/src/Likely Bugs/Underspecified Functions/MistypedFunctionArguments.qll | Same isCompiledAsC rewrite to improve evaluation performance and consistency. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 0
tausbn
approved these changes
Apr 13, 2026
Contributor
tausbn
left a comment
There was a problem hiding this comment.
Shorter and more performant. Hooray!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is one of the predicates showing up in the "Stable join-order badness, per source and predicate" table in our nightly experiments.
Before on Abseil Windows for
cpp/too-few-arguments::After: