@@ -66,8 +66,15 @@ Locatable getATypeUse(Type type) {
6666}
6767
6868private Locatable getATypeUse_i ( Type type ) {
69- // Restrict to uses within the source checkout root
70- exists ( result .getFile ( ) .getRelativePath ( ) ) and
69+ (
70+ // Restrict to uses within the source checkout root
71+ exists ( result .getFile ( ) .getRelativePath ( ) )
72+ or
73+ // Unless it's an alias template instantiation, as they do not have correct locations (last
74+ // verified in CodeQL CLI 2.7.6)
75+ result instanceof UsingAliasTypedefType and
76+ not exists ( result .getLocation ( ) )
77+ ) and
7178 (
7279 // Used as a variable type
7380 exists ( Variable v | result = v |
@@ -143,5 +150,20 @@ private Locatable getATypeUse_i(Type type) {
143150 or
144151 // This is a TemplateClass where one of the specializations is used
145152 type = used .( ClassTemplateSpecialization ) .getPrimaryTemplate ( )
153+ or
154+ // Alias templates - alias templates and instantiations are not properly captured by the
155+ // extractor (last verified in CodeQL CLI 2.7.6). The only distinguishing factor is that
156+ // instantiations of alias templates do not have a location.
157+ exists ( UsingAliasTypedefType template , UsingAliasTypedefType instantiation |
158+ // Instantiation is a "use" of the template
159+ used = instantiation and
160+ type = template and
161+ // The template has a location
162+ exists ( template .getLocation ( ) ) and
163+ // The instantiation does not
164+ not exists ( instantiation .getLocation ( ) ) and
165+ // Template and instantiation both have the same qualified name
166+ template .getQualifiedName ( ) = instantiation .getQualifiedName ( )
167+ )
146168 )
147169}
0 commit comments