[PATCH] D37341: [Sema] Fix an assert-on-invalid by avoiding function template specialisation deduction for invalid functions with fabricated template arguments

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 17:59:32 PDT 2017


vsapsai added a comment.

Does your fix work for deeper nesting too (e.g. template in template in template)? Looks like it should, just want to confirm.

Are there other places where you need to avoid calling `DeduceTemplateArguments` due to templates depth mismatch? `CheckDependentFunctionTemplateSpecialization` should be OK as it's not deducing template arguments. But I'm not sure about `CheckMemberSpecialization`. It doesn't call `DeduceTemplateArguments` directly but I haven't dug deep enough to confirm it's not performing deduction indirectly.



================
Comment at: lib/Sema/SemaDecl.cpp:8307-8308
         isFunctionTemplateSpecialization = true;
+        if (Invalid && TemplateParams->getLAngleLoc().isInvalid())
+          HasFabricatedTemplateSpecializationTemplateParams = true;
         // For source fidelity, store all the template param lists.
----------------
Checking if angle location is invalid looks suspicious. It can be my lack of knowledge but I expect various locations not to convey sema information.


================
Comment at: lib/Sema/SemaDecl.cpp:8880-8881
           << NewFD->getDeclName();
-      } else if (CheckFunctionTemplateSpecialization(NewFD,
+      } else if (!HasFabricatedTemplateSpecializationTemplateParams &&
+                 CheckFunctionTemplateSpecialization(NewFD,
                                   (HasExplicitTemplateArgs ? &TemplateArgs
----------------
Will something more general like

    !NewFD->isInvalidDecl() && CheckFunctionTemplateSpecialization(...)

work here? Because if matching template parameters to scope specifier fails, `NewFD` is marked as invalid decl and seems like we can use that.


Repository:
  rL LLVM

https://reviews.llvm.org/D37341





More information about the cfe-commits mailing list