@@ -187,6 +187,14 @@ class Variable extends Declaration, @variable {
187
187
* `for (char c : str) { ... }`
188
188
*/
189
189
predicate isCompilerGenerated ( ) { compgenerated ( underlyingElement ( this ) ) }
190
+
191
+ /** Holds if this variable is a template specialization. */
192
+ predicate isSpecialization ( ) {
193
+ exists ( VariableDeclarationEntry vde |
194
+ var_decls ( unresolveElement ( vde ) , underlyingElement ( this ) , _, _, _) and
195
+ vde .isSpecialization ( )
196
+ )
197
+ }
190
198
}
191
199
192
200
/**
@@ -267,6 +275,9 @@ class VariableDeclarationEntry extends DeclarationEntry, @var_decl {
267
275
override predicate isDefinition ( ) { var_def ( underlyingElement ( this ) ) }
268
276
269
277
override string getASpecifier ( ) { var_decl_specifiers ( underlyingElement ( this ) , result ) }
278
+
279
+ /** Holds if this declaration is a template specialization. */
280
+ predicate isSpecialization ( ) { var_specialized ( underlyingElement ( this ) ) }
270
281
}
271
282
272
283
/**
@@ -594,7 +605,10 @@ class TemplateVariable extends Variable {
594
605
/**
595
606
* Gets an instantiation of this variable template.
596
607
*/
597
- Variable getAnInstantiation ( ) { result .isConstructedFrom ( this ) }
608
+ Variable getAnInstantiation ( ) {
609
+ result .isConstructedFrom ( this ) and
610
+ not result .isSpecialization ( )
611
+ }
598
612
}
599
613
600
614
/**
@@ -624,6 +638,21 @@ class VariableTemplateInstantiation extends Variable {
624
638
TemplateVariable getTemplate ( ) { result = tv }
625
639
}
626
640
641
+ /**
642
+ * An explicit specialization of a C++ variable template.
643
+ */
644
+ class VariableTemplateSpecialization extends Variable {
645
+ VariableTemplateSpecialization ( ) { this .isSpecialization ( ) }
646
+
647
+ override string getAPrimaryQlClass ( ) { result = "VariableTemplateSpecialization" }
648
+
649
+ /**
650
+ * Gets the primary template for the specialization (the function template
651
+ * this specializes).
652
+ */
653
+ TemplateVariable getPrimaryTemplate ( ) { this .isConstructedFrom ( result ) }
654
+ }
655
+
627
656
/**
628
657
* A non-static local variable or parameter that is not part of an
629
658
* uninstantiated template. Uninstantiated templates are purely syntax, and
0 commit comments