• Hi, I’m trying to get the SourceLocation of a type reference inside an explicit template instantiation declaration, for example: struct Foo {}; template void func(const Foo &) {} // I want the SourceLocation of Foo on this line: template void func<0>(const Foo &); I’ve tried to get the SourceLocation of typeLoc , but return the location from the template definition instead of the instantiation line.
• Is there a correct way to retrieve the SourceLocation of a type reference in the parameter list of an explicit instantiation declaration, or is this information simply not preserved in the AST?
• zwuis 2 AST Nodes of explicit instantiation are missing currently.
• 1 Like
Hi, I’m trying to get the SourceLocation of a type reference inside an explicit template instantiation declaration, for example: struct Foo {}; template void func(const Foo &) {} // I want the SourceLocation of Foo on this line: template void func<0>(const Foo &); I’ve tried to get the SourceLocation of typeLoc , but return the location from the template definition instead of the instantiation line.
• Is there a correct way to retrieve the SourceLocation of a type reference in the parameter list of an explicit instantiation declaration, or is this information simply not preserved in the AST?
• zwuis 2 AST Nodes of explicit instantiation are missing currently.
Article Summaries:
- Hi, I’m trying to get the SourceLocation of a type reference inside an explicit template instantiation declaration, for example: struct Foo {}; template void func(const Foo &) {} // I want the SourceLocation of
Fooon this line: template void func<0>(const Foo &); I’ve tried to get the SourceLocation of typeLoc , but return the location from the template definition instead of the instantiation line. Is there a correct way to retrieve the SourceLocation of a type reference in the parameter list of an explicit instantiation declaration, or is this information simply not preserved in the AST? T
Sources:
- https://discourse.llvm.org/t/how-to-get-correct-typeloc-sourcelocation-for-parameters-in-explicit-template-instantiation/89946 (Latest source article published: 2026-02-24 02:05 UTC)