[PATCH] D17215: [Sema] Fix PR14211 Crash for explicit instantiation of overloaded template function within class template

John McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 15 09:57:04 PST 2016


rjmccall added inline comments.

================
Comment at: lib/Sema/SemaTemplate.cpp:7829
@@ -7828,2 +7828,3 @@
   UnresolvedSet<8> Matches;
+  FunctionDecl *Specialization = nullptr;
   TemplateSpecCandidateSet FailedCandidates(D.getIdentifierLoc());
----------------
Please name this variable NonTemplateMatch instead of Specialization, then initialize the later Specialization variable to it if it's non-null.  That's more self-documenting, and it avoids readability problems with the fact that this loop actually declares its own Specialization variable that would shadow this one.

Please also rename Matches to TemplateMatches.

================
Comment at: lib/Sema/SemaTemplate.cpp:7838
@@ -7836,6 +7837,3 @@
         if (Context.hasSameUnqualifiedType(Method->getType(), Adjusted)) {
-          Matches.clear();
-
-          Matches.addDecl(Method, P.getAccess());
-          if (Method->getTemplateSpecializationKind() == TSK_Undeclared)
-            break;
+          if (cast<FunctionDecl>(Method)->getPrimaryTemplate()){
+            Matches.clear();
----------------
This cast shouldn't be necessary.  CXXMethodDecl is a subclass of FunctionDecl.


http://reviews.llvm.org/D17215





More information about the cfe-commits mailing list