On 18/11/15 20:49, David Majnemer via cfe-commits wrote:
Author: majnemer
Date: Wed Nov 18 13:49:19 2015
New Revision: 253495

URL: http://llvm.org/viewvc/llvm-project?rev=253495&view=rev
Log:
[Sema] Don't work around a malformed AST

We created a malformed TemplateSpecializationType: it was dependent but
had a RecordType as it's canonical type.  This would lead getAs to
crash.  r249090 worked around this but we should fix this for real by
providing a more appropriate template specialization type as the
canonical type.

This fixes PR24246.

Modified:
     cfe/trunk/lib/Sema/SemaLookup.cpp
     cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=253495&r1=253494&r2=253495&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Nov 18 13:49:19 2015
@@ -3890,8 +3890,6 @@ void TypoCorrectionConsumer::addNamespac
    auto &Types = SemaRef.getASTContext().getTypes();
    for (unsigned I = 0; I != Types.size(); ++I) {
      const auto *TI = Types[I];
-    if (!TI->isClassType() && isa<TemplateSpecializationType>(TI))
-      continue;
      if (CXXRecordDecl *CD = TI->getAsCXXRecordDecl()) {
        CD = CD->getCanonicalDecl();
        if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=253495&r1=253494&r2=253495&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Nov 18 13:49:19 2015
@@ -6408,7 +6408,17 @@ Sema::ActOnClassTemplateSpecialization(S
      if (!PrevDecl)
        ClassTemplate->AddSpecialization(Specialization, InsertPos);
- CanonType = Context.getTypeDeclType(Specialization);
+    if (CurContext->isDependentContext()) {
+      // -fms-extensions permits specialization of nested classes without
+      // fully specializing the outer class(es).
+      assert(getLangOpts().MicrosoftExt &&
+             "Only possible with -fms-extensions!");
+      TemplateName CanonTemplate = Context.getCanonicalTemplateName(Name);
+      CanonType = Context.getTemplateSpecializationType(
Out of curiosity, could we use getCanonicalTemplateSpecializationType here and produce one less type?
+          CanonTemplate, Converted.data(), Converted.size());
+    } else {
+      CanonType = Context.getTypeDeclType(Specialization);
+    }
    }
// C++ [temp.expl.spec]p6:


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to