From 8c2d3f424834f765b89ceb8cf5df0da57803fc24 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 4 Mar 2011 20:42:52 +0000 Subject: [PATCH] After an error of any kind has occurred, don't assert when attempting to find the instantiated declaration within a template instantiation fails to do so. It's likely that the original instantiation got dropped due to instantiation failures, which doesn't actually break the invariants of the AST. This eliminates a number of crash-on-invalid failures, e.g., PR9300. llvm-svn: 127030 --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 577c2c28c47c..3473c877093c 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3031,9 +3031,11 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, } // UsingShadowDecls can instantiate to nothing because of using hiding. - assert((Result || isa(D) || D->isInvalidDecl() || - cast(ParentDC)->isInvalidDecl()) - && "Unable to find instantiation of declaration!"); + // Note: this assertion end up firing in invalid code even when none of the + // AST invariants have been broken, so we explicitly check whether any + // errors have been emitted + assert((Result || isa(D) || Diags.hasErrorOccurred()) && + "Unable to find instantiation of declaration!"); D = Result; }