-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Open
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Description
Our substitution of alias templates is leaving behind a SubstTemplateTypeParmType pointing to TemplateTypeParmType with incorrect depth.
Example: (https://godbolt.org/z/r3GPj7GGn)
template<class T> struct C {
template<class U> using type1 = U (T);
};
using type2 = typename C<int>::type1<void>;
AST dump of type2:
`-TypeAliasDecl 0x56240cfed3e8 <line:4:1, col:42> col:7 type2 'typename C<int>::type1<void>':'void (int)'
`-ElaboratedType 0x56240cfed340 'typename C<int>::type1<void>' sugar
`-TemplateSpecializationType 0x56240cfce350 'type1<void>' sugar alias type1
|-TemplateArgument type 'void'
| `-BuiltinType 0x56240cf831b0 'void'
`-FunctionProtoType 0x56240cfce2f0 'void (int)' cdecl
|-SubstTemplateTypeParmType 0x56240cfce290 'void' sugar
| |-TemplateTypeParmType 0x56240cfcdfa0 'U' dependent depth 0 index 0
| | `-TemplateTypeParm 0x56240cfcdf50 'U'
| `-BuiltinType 0x56240cf831b0 'void'
`-SubstTemplateTypeParmType 0x56240cfcdfe0 'int' sugar
|-TemplateTypeParmType 0x56240cfcd590 'T' dependent depth 0 index 0
| `-TemplateTypeParm 0x56240cfcd510 'T'
`-BuiltinType 0x56240cf83250 'int'
Ie notice in the AST both T and U are at the same depth, 0.
This happens because we substitute T early into the alias, which pulls U down one level, and then we substitute U.
This flattens everything down to ground level.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"