mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
C++: Add VariableTemplateInstantiation class
This adds some uniformity, as we already had `FunctionTemplateInstantiation` and `ClassTemplateInstantiation` classes.
This commit is contained in:
@@ -590,6 +590,33 @@ class TemplateVariable extends Variable {
|
||||
Variable getAnInstantiation() { result.isConstructedFrom(this) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A variable that is an instantiation of a template. For example
|
||||
* the instantiation `myTemplateVariable<int>` in the following code:
|
||||
* ```
|
||||
* template<class T>
|
||||
* T myTemplateVariable;
|
||||
*
|
||||
* void caller(int i) {
|
||||
* myTemplateVariable<int> = i;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
class VariableTemplateInstantiation extends Variable {
|
||||
TemplateVariable tv;
|
||||
|
||||
VariableTemplateInstantiation() { tv.getAnInstantiation() = this }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "VariableTemplateInstantiation" }
|
||||
|
||||
/**
|
||||
* Gets the variable template from which this instantiation was instantiated.
|
||||
*
|
||||
* Example: For `int x<int>`, returns `T x`.
|
||||
*/
|
||||
TemplateVariable getTemplate() { result = tv }
|
||||
}
|
||||
|
||||
/**
|
||||
* A non-static local variable or parameter that is not part of an
|
||||
* uninstantiated template. Uninstantiated templates are purely syntax, and
|
||||
|
||||
Reference in New Issue
Block a user