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 {
590
590
Variable getAnInstantiation ( ) { result .isConstructedFrom ( this ) }
591
591
}
592
592
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
+
593
620
/**
594
621
* A non-static local variable or parameter that is not part of an
595
622
* uninstantiated template. Uninstantiated templates are purely syntax, and
Original file line number Diff line number Diff line change @@ -15605,7 +15605,7 @@ ir.cpp:
15605
15605
# 1934| Type = [ClassTemplateInstantiation,Struct] Bar2<int>
15606
15606
# 1934| ValueCategory = lvalue
15607
15607
# 1935| getStmt(2): [ReturnStmt] return ...
15608
- # 1938| [GlobalVariable] char global_template<char>
15608
+ # 1938| [GlobalVariable,VariableTemplateInstantiation ] char global_template<char>
15609
15609
# 1938| getInitializer(): [Initializer] initializer for global_template
15610
15610
# 1938| getExpr(): [Literal] 42
15611
15611
# 1938| Type = [IntType] int
@@ -15616,7 +15616,7 @@ ir.cpp:
15616
15616
# 1938| Type = [PlainCharType] char
15617
15617
# 1938| Value = [CStyleCast] 42
15618
15618
# 1938| ValueCategory = prvalue
15619
- # 1938| [GlobalVariable] int global_template<int>
15619
+ # 1938| [GlobalVariable,VariableTemplateInstantiation ] int global_template<int>
15620
15620
# 1938| getInitializer(): [Initializer] initializer for global_template
15621
15621
# 1938| getExpr(): [Literal] 42
15622
15622
# 1938| Type = [IntType] int
You can’t perform that action at this time.
0 commit comments