C++: Support alias templates#21860
Merged
Merged
Conversation
Add other missing cases to `isFromTemplateInstantiationRec` and `isFromUninstantiatedTemplateRec` while here.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class CodeQL support for C++ alias templates and their instantiations. It introduces new dbscheme tables (is_alias_template, alias_instantiation, alias_template_argument, alias_template_argument_value), corresponding QL classes (TypeAliasType, AliasTemplateType, AliasTemplateInstantiationType), deprecates the existing UsingAliasTypedefType in favor of TypeAliasType, and wires alias templates into existing template-instantiation detection helpers.
Changes:
- Extend dbscheme with new alias-template relations and provide upgrade/downgrade scripts.
- Rename
UsingAliasTypedefTypetoTypeAliasType(deprecation stub kept) and addAliasTemplateType/AliasTemplateInstantiationType. - Teach
Element.qllandDeclaration.qllabout alias templates (and template-template parameters / concepts) for instantiation/argument lookup.
Show a summary per file
| File | Description |
|---|---|
| cpp/ql/lib/semmlecode.cpp.dbscheme | Adds new alias-template relations. |
| cpp/ql/lib/upgrades/770002bb02322e04fa25345838ce6e82af285a0b/{old.dbscheme,upgrade.properties} | Upgrade scaffolding for the dbscheme change. |
| cpp/downgrades/837c4e02326aee4582405d069263092e80a15d82/{semmlecode.cpp.dbscheme,upgrade.properties} | Downgrade to a scheme without the new relations. |
| cpp/ql/lib/semmle/code/cpp/TypedefType.qll | Introduces TypeAliasType/AliasTemplateType/AliasTemplateInstantiationType and deprecates UsingAliasTypedefType. |
| cpp/ql/lib/semmle/code/cpp/Element.qll | Includes alias templates (and template-template parameters/concepts) in template instantiation detection. |
| cpp/ql/lib/semmle/code/cpp/Declaration.qll | Exposes alias-template arguments via getTemplateArgument. |
| cpp/ql/lib/change-notes/2026-05-16-alias-template.md | New feature note. |
| cpp/ql/lib/change-notes/2026-05-18-alias-type.md | Deprecation note for UsingAliasTypedefType. |
| cpp/ql/test/library-tests/using-aliases/using-alias.expected | Updated to reflect renamed class. |
| cpp/ql/test/library-tests/ir/ir/PrintAST.expected | Updated to reflect renamed class. |
Copilot's findings
- Files reviewed: 14/15 changed files
- Comments generated: 4
Comment on lines
+969
to
+974
| int variable_id: @usertype ref, | ||
| int index: int ref, | ||
| int arg_type: @type ref | ||
| ); | ||
| alias_template_argument_value( | ||
| int variable_id: @usertype ref, |
Contributor
Author
There was a problem hiding this comment.
The name is not really relevant. I've another scheme update in the pipeline. I'll fix this as part of that update.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Introduce new classes exposing alias templates and their instantiations. While here, simplify the naming of type aliases.
Commit-by-commit reviewer recommended.