From: Chris Lattner Date: Thu, 17 Feb 2011 19:38:27 +0000 (+0000) Subject: remove some defensive code: LocalInstantiationScope::getInstantiationOf X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a70062ff988eb1fc4a159e463a2a3de5155b7f6a;p=clang remove some defensive code: LocalInstantiationScope::getInstantiationOf and findInstantiationOf can never return null, even on invalid code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125769 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index f58e744578..0ad9f7c53f 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -2168,8 +2168,7 @@ bool Sema::Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, Decl *LocalInstantiationScope::getInstantiationOf(const Decl *D) { llvm::PointerUnion *Found= findInstantiationOf(D); - if (!Found) - return 0; + assert(Found); if (Found->is()) return Found->get(); @@ -2202,8 +2201,7 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { break; } - assert(D->isInvalidDecl() && - "declaration was not instantiated in this scope!"); + assert(0 && "declaration was not instantiated in this scope!"); return 0; } diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp index a49c23b1df..0da801c7e3 100644 --- a/lib/Sema/SemaTemplateVariadic.cpp +++ b/lib/Sema/SemaTemplateVariadic.cpp @@ -503,8 +503,7 @@ bool Sema::CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, llvm::PointerUnion *Instantiation = CurrentInstantiationScope->findInstantiationOf( Unexpanded[I].first.get()); - if (Instantiation && - Instantiation->is()) { + if (Instantiation->is()) { // We could expand this function parameter pack. NewPackSize = Instantiation->get()->size(); } else { @@ -594,7 +593,7 @@ unsigned Sema::getNumArgumentsInExpansion(QualType T, llvm::PointerUnion *Instantiation = CurrentInstantiationScope->findInstantiationOf( Unexpanded[I].first.get()); - if (Instantiation && Instantiation->is()) + if (Instantiation->is()) return Instantiation->get()->size(); continue;