[PATCH] D38320: [clang] Fix serializers for `TypeTemplateParmDecl` + related types

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 31 14:06:54 PDT 2018

rsmith added inline comments.

Comment at: lib/Serialization/ASTReaderDecl.cpp:3448-3456
       if (!inheritDefaultTemplateArgument(Context, FTTP, ToParam))
     } else if (auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam)) {
       if (!inheritDefaultTemplateArgument(Context, FNTTP, ToParam))
     } else {
       if (!inheritDefaultTemplateArgument(
The idea is to reconstruct the 'inherited default template argument' information when we read a template declaration and find it's a redeclaration of another one, rather than serializing it and deserializing it. (In particular, if an imported template redeclares a non-imported template or a template imported from an unrelated module, it won't know that the prior declaration had a default argument because it doesn't know what the prior declaration was.)

The problem with our implementation of that idea is these `break`s: we're (incorrectly) assuming that a template parameter cannot have a default argument if there's a later template parameter that does not have one.

I removed the `break`s in r338438, and it fixed your testcase (which I committed alongside that change). Can you check to see if that also fixes the original problem from which this was reduced? Thanks!

  rC Clang


More information about the cfe-commits mailing list