mirror of
https://github.com/github/codeql.git
synced 2026-04-20 14:34:04 +02:00
Merge pull request #18362 from github/jketema/template-parameters-4
C++: Support concept templates
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user