Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++: Introduce a new base class for template parameters #18308

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

jketema
Copy link
Contributor

@jketema jketema commented Dec 17, 2024

This will enable us to support non-type template parameters, which we currently do not support, and error template parameters, which might become relevant in the build-mode: none context.

DCA was ran on the internal PR.

Pull Request checklist

All query authors

Internal query authors only

  • Autofixes generated based on these changes are valid, only needed if this PR makes significant changes to .ql, .qll, or .qhelp files. See the documentation (internal access required).
  • Changes are validated at scale (internal access required).
  • Adding a new query? Consider also adding the query to autofix.

@jketema jketema force-pushed the template-parameters branch 2 times, most recently from 94e9b6e to fda2d75 Compare December 17, 2024 18:28
@jketema jketema added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label Dec 17, 2024
This will enable us to support non-type template parameters, which we
currently do not support, and error template parameters, which might
become relevant in the `build-mode: none` context.
@jketema jketema force-pushed the template-parameters branch from fda2d75 to b7d1da8 Compare December 17, 2024 19:26
---
category: feature
---
* A new class `TemplateParameterBase` was introduced, which represents C++ non-type template parameters, type template parameters, and template template parameters.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, this is currently a lie, as nothing represents non-type template parameters. I plan to fix this next.

@jketema jketema marked this pull request as ready for review December 17, 2024 22:49
@jketema jketema requested a review from a team as a code owner December 17, 2024 22:49
@@ -1695,7 +1717,7 @@ class TemplateParameter extends UserType {
* void foo(const Container<Elem> &value) { }
* ```
*/
class TemplateTemplateParameter extends TemplateParameter {
class TemplateTemplateParameter extends TypeTemplateParameter {
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the description in the change note I thought that type template parameters and template template parameters where to different groups and wouldn't have expected TemplateTemplateParameter to extend TypeTemplateParameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could pull that apart, but that will have quite some fallout in other places, and possibly for customers. So, I prefer to leave this as-is. Another observation is that template template parameters will still refer to (templated) types, so from that perspective it makes sense to have this layering, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks. Let's keep it like this then :)

Comment on lines 1676 to 1679
* In the example below, `T` and `I` are template parameters:
* ```
* template <class T, int I>
* class C { };
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be nice to add a template template parameter as well:

Suggested change
* In the example below, `T` and `I` are template parameters:
* ```
* template <class T, int I>
* class C { };
* In the example below, `T`, `I`, and `V` are template parameters:
* ```
* template <class T, int I, template<typename> class V>
* class C { };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in ccd3681

@jketema jketema merged commit 66b2b5d into github:main Dec 18, 2024
14 of 16 checks passed
@jketema jketema deleted the template-parameters branch December 18, 2024 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ depends on internal PR This PR should only be merged in sync with an internal Semmle PR documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants