I want to figure out how the ASTContext::getCanonicalTemplateTemplateParmDecl function should work. For a class template partial specialization object and TemplateTemplateParmDecl in a TemplateArgument, the function is called from getCanonicalTemplateArgument. It creates a new not initialized TemplateTemplateParmDecl object that is used in the new TemplateName and TemplateArgument. The TemplateName now contains an uninitialized TemplateTemplateParmDecl that is not linked to the old (and correct) TemplateTemplateParmDecl. At least when the function is called from ASTReader::ReadTemplateArgument.

Can somebody tell if this is a bug or how the code (ReadTemplateArgument if Canonicalize==true) should work? This code was introduced in commit 47ba20a (“[modules] When loading a template specialization, re-canonicalize its…”) years ago.