mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
C++: Basic lib support for template param values
This commit is contained in:
@@ -614,6 +614,15 @@ class Class extends UserType {
|
||||
class_template_argument(underlyingElement(this), i, unresolveElement(result))
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the `i`th template argument value used to instantiate this class from a
|
||||
* class template. When called on a class template, this will return the
|
||||
* `i`th template parameter value.
|
||||
*/
|
||||
override Expr getTemplateArgumentValue(int i) {
|
||||
class_template_argument_value(underlyingElement(this), i, unresolveElement(result))
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this class/struct is polymorphic (has a virtual function, or
|
||||
* inherits one).
|
||||
|
||||
@@ -203,6 +203,13 @@ abstract class Declaration extends Locatable, @declaration {
|
||||
*/
|
||||
Type getTemplateArgument(int index) { none() }
|
||||
|
||||
/**
|
||||
* Gets the `i`th template argument value used to instantiate this declaration
|
||||
* from a template. When called on a template, this will return the `i`th template
|
||||
* parameter value if it exists.
|
||||
*/
|
||||
Expr getTemplateArgumentValue(int index) { none() }
|
||||
|
||||
/** Gets the number of template arguments for this declaration. */
|
||||
final int getNumberOfTemplateArguments() {
|
||||
result = count(int i | exists(getTemplateArgument(i)))
|
||||
|
||||
@@ -352,6 +352,16 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
|
||||
function_template_argument(underlyingElement(this), index, unresolveElement(result))
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the `i`th template argument used to instantiate this
|
||||
* function from a function template if that argument was a 'non-type'
|
||||
* argument. When called on a function template, this with return the value
|
||||
* of the `i`th template parameter.
|
||||
*/
|
||||
override Expr getTemplateArgumentValue(int index) {
|
||||
function_template_argument_value(underlyingElement(this), index, unresolveElement(result))
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function is defined in several files. This is illegal in
|
||||
* C (though possible in some C++ compilers), and likely indicates that
|
||||
|
||||
@@ -164,6 +164,15 @@ class Variable extends Declaration, @variable {
|
||||
variable_template_argument(underlyingElement(this), index, unresolveElement(result))
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the `i`th template argument value used to instantiate this variable from a
|
||||
* variable template. When called on a variable template, this will return the
|
||||
* `i`th template parameter value.
|
||||
*/
|
||||
override Expr getTemplateArgumentValue(int index) {
|
||||
variable_template_argument_value(underlyingElement(this), index, unresolveElement(result))
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this is a compiler-generated variable. For example, a
|
||||
* [range-based for loop](http://en.cppreference.com/w/cpp/language/range-for)
|
||||
|
||||
Reference in New Issue
Block a user