This is an archive of the discontinued LLVM Phabricator instance.

[clang] Store the template param list of an explicit variable template specialization
ClosedPublic

Authored by nridge on Jan 26 2023, 11:23 PM.

Details

Summary

VarTemplateSpecializationDecl does not store a template param list,
so the "template<>" needs to be stored in the ExtInfo.

Diff Detail

Event Timeline

nridge created this revision.Jan 26 2023, 11:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 11:23 PM
nridge requested review of this revision.Jan 26 2023, 11:23 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 26 2023, 11:23 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

So far the only test I added is in clangd semantic highlighting because that's how I noticed the template<> missing from the AST, but I'm open to suggestions on where to add a test at the clang layer.

shafik added subscribers: Restricted Project, shafik.Jan 30 2023, 8:12 AM

Adding clang-language-wg for more visibility.

We have a good amount of AST-dump tests around that are likely the right place to put them perhaps? What is the reproducer that caused you to discover this issue?

We have a good amount of AST-dump tests around that are likely the right place to put them perhaps? What is the reproducer that caused you to discover this issue?

The following is sufficient to reproduce:

template <typename T>
T x = {};

template <>
int x<int> = 42;

However, the patch does not alter the ast-dump (it looks like the template param lists stored in DeclaratorDecl's getExtInfo()->TemplParamLists are not printed).

Review ping :)

erichkeane accepted this revision.Mar 13 2023, 7:28 AM

sorry for the delay, just started unburying myself from the 16.0 release process. Its unfortunate we don't have a great way to test this, but I can see the value of having it anyway in clangd.

This revision is now accepted and ready to land.Mar 13 2023, 7:28 AM
This revision was landed with ongoing or failed builds.Mar 14 2023, 12:03 AM
This revision was automatically updated to reflect the committed changes.