mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #18362 from github/jketema/template-parameters-4
C++: Support concept templates
This commit is contained in:
2377
cpp/downgrades/f786eb3f5dfddb0ac914ab09551bf1c5c64b47c0/old.dbscheme
Normal file
2377
cpp/downgrades/f786eb3f5dfddb0ac914ab09551bf1c5c64b47c0/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
description: Support concept templates
|
||||
compatibility: full
|
||||
concept_templates.rel: delete
|
||||
concept_template_argument.rel: delete
|
||||
concept_template_argument_value.rel: delete
|
||||
5
cpp/ql/lib/change-notes/2024-12-23-concept-template.md
Normal file
5
cpp/ql/lib/change-notes/2024-12-23-concept-template.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
category: feature
|
||||
---
|
||||
* A new class `Concept` was introduced, which represents C++20 concepts.
|
||||
* The `getTemplateArgumentType` and `getTemplateArgumentValue` predicates of the `Declaration` class now also yield template arguments of concepts.
|
||||
@@ -159,3 +159,32 @@ class ConceptIdExpr extends RequirementExpr, @concept_id {
|
||||
|
||||
override string getAPrimaryQlClass() { result = "ConceptIdExpr" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A C++ concept.
|
||||
*
|
||||
* For example:
|
||||
* ```cpp
|
||||
* template<class T>
|
||||
* concept C = std::is_same<T, int>::value;
|
||||
* ```
|
||||
*/
|
||||
class Concept extends Declaration, @concept_template {
|
||||
override string getAPrimaryQlClass() { result = "Concept" }
|
||||
|
||||
override Location getLocation() { concept_templates(underlyingElement(this), _, result) }
|
||||
|
||||
override string getName() { concept_templates(underlyingElement(this), result, _) }
|
||||
|
||||
/**
|
||||
* Gets the constraint expression of the concept.
|
||||
*
|
||||
* For example, in
|
||||
* ```cpp
|
||||
* template<class T>
|
||||
* concept C = std::is_same<T, int>::value;
|
||||
* ```
|
||||
* the constraint expression is `std::is_same<T, int>::value`.
|
||||
*/
|
||||
Expr getExpr() { result.getParent() = this }
|
||||
}
|
||||
|
||||
@@ -279,6 +279,8 @@ class Declaration extends Locatable, @declaration {
|
||||
variable_template_argument(underlyingElement(this), index, unresolveElement(result))
|
||||
or
|
||||
template_template_argument(underlyingElement(this), index, unresolveElement(result))
|
||||
or
|
||||
concept_template_argument(underlyingElement(this), index, unresolveElement(result))
|
||||
}
|
||||
|
||||
private Expr getTemplateArgumentValue(int index) {
|
||||
@@ -289,6 +291,8 @@ class Declaration extends Locatable, @declaration {
|
||||
variable_template_argument_value(underlyingElement(this), index, unresolveElement(result))
|
||||
or
|
||||
template_template_argument_value(underlyingElement(this), index, unresolveElement(result))
|
||||
or
|
||||
concept_template_argument_value(underlyingElement(this), index, unresolveElement(result))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -876,6 +876,24 @@ template_template_argument_value(
|
||||
int arg_value: @expr ref
|
||||
);
|
||||
|
||||
@concept = @concept_template | @concept_id;
|
||||
|
||||
concept_templates(
|
||||
unique int concept_id: @concept_template,
|
||||
string name: string ref,
|
||||
int location: @location_default ref
|
||||
);
|
||||
concept_template_argument(
|
||||
int concept_id: @concept ref,
|
||||
int index: int ref,
|
||||
int arg_type: @type ref
|
||||
);
|
||||
concept_template_argument_value(
|
||||
int concept_id: @concept ref,
|
||||
int index: int ref,
|
||||
int arg_value: @expr ref
|
||||
);
|
||||
|
||||
routinetypes(
|
||||
unique int id: @routinetype,
|
||||
int return_type: @type ref
|
||||
@@ -1106,7 +1124,8 @@ frienddecls(
|
||||
| @declaredtype
|
||||
| @variable
|
||||
| @enumconstant
|
||||
| @frienddecl;
|
||||
| @frienddecl
|
||||
| @concept_template;
|
||||
|
||||
@member = @membervariable
|
||||
| @function
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Support concept templates
|
||||
compatibility: partial
|
||||
Reference in New Issue
Block a user