зеркало из https://github.com/github/codeql.git
Merge pull request #16069 from jketema/var-templ
C++: Add `VariableTemplateInstantiation` class
This commit is contained in:
Коммит
8711232a38
|
@ -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
|
||||
|
|
|
@ -15605,7 +15605,7 @@ ir.cpp:
|
|||
# 1934| Type = [ClassTemplateInstantiation,Struct] Bar2<int>
|
||||
# 1934| ValueCategory = lvalue
|
||||
# 1935| getStmt(2): [ReturnStmt] return ...
|
||||
# 1938| [GlobalVariable] char global_template<char>
|
||||
# 1938| [GlobalVariable,VariableTemplateInstantiation] char global_template<char>
|
||||
# 1938| getInitializer(): [Initializer] initializer for global_template
|
||||
# 1938| getExpr(): [Literal] 42
|
||||
# 1938| Type = [IntType] int
|
||||
|
@ -15616,7 +15616,7 @@ ir.cpp:
|
|||
# 1938| Type = [PlainCharType] char
|
||||
# 1938| Value = [CStyleCast] 42
|
||||
# 1938| ValueCategory = prvalue
|
||||
# 1938| [GlobalVariable] int global_template<int>
|
||||
# 1938| [GlobalVariable,VariableTemplateInstantiation] int global_template<int>
|
||||
# 1938| getInitializer(): [Initializer] initializer for global_template
|
||||
# 1938| getExpr(): [Literal] 42
|
||||
# 1938| Type = [IntType] int
|
||||
|
|
Загрузка…
Ссылка в новой задаче