From 43556c14fe5ab356a17519f6f3da68f18450df47 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Thu, 3 Nov 2016 15:04:58 +0000 Subject: [Sema] Avoid instantiating templates only when UncompilableErrorOccurred and FatalErrorOccurred are both set. This fixes a crash that occurs when a warning promoted to a fatal error leaves the AST in an incomplete state, and then later CFG analysis is run on the incomplete AST. rdar://problem/28558923 Differential Revision: https://reviews.llvm.org/D26166 llvm-svn: 285923 --- clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp') diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index b715c13b077..6e715d25b4d 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -209,9 +209,11 @@ Sema::InstantiatingTemplate::InstantiatingTemplate( sema::TemplateDeductionInfo *DeductionInfo) : SemaRef(SemaRef), 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()) { + // Don't allow further instantiation if a fatal error and an uncompilable + // error have occcured. Any diagnostics we might have raised will not be + // visible, and we do not need to construct a correct AST. + if (SemaRef.Diags.hasFatalErrorOccurred() && + SemaRef.Diags.hasUncompilableErrorOccurred()) { Invalid = true; return; } -- cgit v1.2.3