Skip to content

C++: Support alias templates#21860

Merged
jketema merged 8 commits into
github:mainfrom
jketema:jketema/alias-template
May 19, 2026
Merged

C++: Support alias templates#21860
jketema merged 8 commits into
github:mainfrom
jketema:jketema/alias-template

Conversation

@jketema
Copy link
Copy Markdown
Contributor

@jketema jketema commented May 18, 2026

Introduce new classes exposing alias templates and their instantiations. While here, simplify the naming of type aliases.

Commit-by-commit reviewer recommended.

@jketema jketema added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label May 18, 2026
@github-actions github-actions Bot added C++ documentation and removed depends on internal PR This PR should only be merged in sync with an internal Semmle PR labels May 18, 2026
Comment thread cpp/ql/lib/semmle/code/cpp/Element.qll Dismissed
@jketema jketema marked this pull request as ready for review May 18, 2026 12:56
@jketema jketema requested a review from a team as a code owner May 18, 2026 12:56
Copilot AI review requested due to automatic review settings May 18, 2026 12:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 UsingAliasTypedefType to TypeAliasType (deprecation stub kept) and add AliasTemplateType / AliasTemplateInstantiationType.
  • Teach Element.qll and Declaration.qll about 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,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is not really relevant. I've another scheme update in the pipeline. I'll fix this as part of that update.

Comment thread cpp/ql/lib/semmle/code/cpp/TypedefType.qll Outdated
Comment thread cpp/ql/lib/semmle/code/cpp/TypedefType.qll Outdated
Comment thread cpp/ql/lib/change-notes/2026-05-16-alias-template.md Outdated
Copy link
Copy Markdown
Contributor

@IdrissRio IdrissRio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jketema jketema merged commit 22a8123 into github:main May 19, 2026
20 of 22 checks passed
@jketema jketema deleted the jketema/alias-template branch May 19, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants