File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -590,6 +590,33 @@ class TemplateVariable extends Variable {
590590 Variable getAnInstantiation ( ) { result .isConstructedFrom ( this ) }
591591}
592592
593+ /**
594+ * A variable that is an instantiation of a template. For example
595+ * the instantiation `myTemplateVariable<int>` in the following code:
596+ * ```
597+ * template<class T>
598+ * T myTemplateVariable;
599+ *
600+ * void caller(int i) {
601+ * myTemplateVariable<int> = i;
602+ * }
603+ * ```
604+ */
605+ class VariableTemplateInstantiation extends Variable {
606+ TemplateVariable tv ;
607+
608+ VariableTemplateInstantiation ( ) { tv .getAnInstantiation ( ) = this }
609+
610+ override string getAPrimaryQlClass ( ) { result = "VariableTemplateInstantiation" }
611+
612+ /**
613+ * Gets the variable template from which this instantiation was instantiated.
614+ *
615+ * Example: For `int x<int>`, returns `T x`.
616+ */
617+ TemplateVariable getTemplate ( ) { result = tv }
618+ }
619+
593620/**
594621 * A non-static local variable or parameter that is not part of an
595622 * uninstantiated template. Uninstantiated templates are purely syntax, and
Original file line number Diff line number Diff line change @@ -15605,7 +15605,7 @@ ir.cpp:
1560515605# 1934| Type = [ClassTemplateInstantiation,Struct] Bar2<int>
1560615606# 1934| ValueCategory = lvalue
1560715607# 1935| getStmt(2): [ReturnStmt] return ...
15608- # 1938| [GlobalVariable] char global_template<char>
15608+ # 1938| [GlobalVariable,VariableTemplateInstantiation ] char global_template<char>
1560915609# 1938| getInitializer(): [Initializer] initializer for global_template
1561015610# 1938| getExpr(): [Literal] 42
1561115611# 1938| Type = [IntType] int
@@ -15616,7 +15616,7 @@ ir.cpp:
1561615616# 1938| Type = [PlainCharType] char
1561715617# 1938| Value = [CStyleCast] 42
1561815618# 1938| ValueCategory = prvalue
15619- # 1938| [GlobalVariable] int global_template<int>
15619+ # 1938| [GlobalVariable,VariableTemplateInstantiation ] int global_template<int>
1562015620# 1938| getInitializer(): [Initializer] initializer for global_template
1562115621# 1938| getExpr(): [Literal] 42
1562215622# 1938| Type = [IntType] int
You can’t perform that action at this time.
0 commit comments