Sema: Disable template instantiation once a fatal error is raised
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 30 Jan 2015 05:01:23 +0000 (05:01 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 30 Jan 2015 05:01:23 +0000 (05:01 +0000)
Fatal errors disable all further diagnostics.  Continuing to permit
template instantiation does nothing but make it take longer for clang to
finish with the TU.

Instead, halt all further instantiation.

Fixed in PR22396.

llvm-svn: 227556

clang/lib/Sema/SemaTemplateInstantiate.cpp

index 6ac7175..ed0d5a5 100644 (file)
@@ -207,6 +207,12 @@ void Sema::InstantiatingTemplate::Initialize(
     sema::TemplateDeductionInfo *DeductionInfo) {
   SavedInNonInstantiationSFINAEContext =
       SemaRef.InNonInstantiationSFINAEContext;
+  // Don't allow further instantiation if a fatal error has occcured.  Any
+  // diagnostics we might have raised will not be visible.
+  if (SemaRef.Diags.hasFatalErrorOccurred()) {
+    Invalid = true;
+    return;
+  }
   Invalid = CheckInstantiationDepth(PointOfInstantiation, InstantiationRange);
   if (!Invalid) {
     ActiveTemplateInstantiation Inst;