C++: Mark initializers of compiler-generated variables as compiler-generated - #22406
Merged
MathiasVP merged 5 commits intoAug 21, 2026
Merged
Conversation
…variables as compiler-generated.
jketema
reviewed
Aug 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Marks initializers of compiler-generated C++ variables, and their expressions, as compiler-generated.
Changes:
- Adds
Initializer.isCompilerGenerated(). - Propagates compiler-generated status to initializer expressions.
- Adds coverage using
__PRETTY_FUNCTION__.
Show a summary per file
| File | Description |
|---|---|
cpp/ql/lib/semmle/code/cpp/Initializer.qll |
Adds initializer classification. |
cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll |
Propagates classification to expressions. |
cpp/ql/test/library-tests/compiler_generated/cpp.cpp |
Adds test input. |
cpp/ql/test/library-tests/compiler_generated/compilerGenerated.ql |
Queries generated initializers. |
cpp/ql/test/library-tests/compiler_generated/compilerGenerated.expected |
Updates expected results. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
…'s generated by the frontend on empty parameter packs.
jketema
reviewed
Aug 21, 2026
Comment on lines
+59
to
+66
| predicate isCompilerGenerated() { | ||
| exists(Variable v | | ||
| v = this.getDeclaration() and | ||
| // We require the variable to be an orphan to not mark the initializer | ||
| // from a desugared ranged for loop as compiler generated. | ||
| orphaned_variables(unresolveElement(v), _) and | ||
| v.isCompilerGenerated() | ||
| ) |
Contributor
There was a problem hiding this comment.
This is really an edge case, but I wonder whether there are some initializers related to coroutines that should be marked as compiler generated? However, we can always deal with those when the need arises (no immediate need here).
Contributor
Author
|
DCA was uneventful (as expected). Merging! |
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.
Pretty simple stuff. If a variable is compiler-generated surely the initializer is also compiler generated. So this PR marks it as such.