]> granicus.if.org Git - clang/commitdiff
remove some defensive code: LocalInstantiationScope::getInstantiationOf
authorChris Lattner <sabre@nondot.org>
Thu, 17 Feb 2011 19:38:27 +0000 (19:38 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 17 Feb 2011 19:38:27 +0000 (19:38 +0000)
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

lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/SemaTemplateVariadic.cpp

index f58e744578a5b00bba83992b7e19b3f1f45793d3..0ad9f7c53fb3fd0874a989887b93e81c1a4c2b05 100644 (file)
@@ -2168,8 +2168,7 @@ bool Sema::Subst(const TemplateArgumentLoc *Args, unsigned NumArgs,
 
 Decl *LocalInstantiationScope::getInstantiationOf(const Decl *D) {
   llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found= findInstantiationOf(D);
-  if (!Found)
-    return 0;
+  assert(Found);
   
   if (Found->is<Decl *>())
     return Found->get<Decl *>();
@@ -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;
 }
 
index a49c23b1df8d2cbe0a71688302ce8a351f214d74..0da801c7e343ce2154d1bc738cda1bfb13353305 100644 (file)
@@ -503,8 +503,7 @@ bool Sema::CheckParameterPacksForExpansion(SourceLocation EllipsisLoc,
       llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation
         = CurrentInstantiationScope->findInstantiationOf(
                                         Unexpanded[I].first.get<NamedDecl *>());
-      if (Instantiation &&
-          Instantiation->is<DeclArgumentPack *>()) {
+      if (Instantiation->is<DeclArgumentPack *>()) {
         // We could expand this function parameter pack.
         NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
       } else {
@@ -594,7 +593,7 @@ unsigned Sema::getNumArgumentsInExpansion(QualType T,
         llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation
           = CurrentInstantiationScope->findInstantiationOf(
                                         Unexpanded[I].first.get<NamedDecl *>());
-        if (Instantiation && Instantiation->is<DeclArgumentPack *>())
+        if (Instantiation->is<DeclArgumentPack *>())
           return Instantiation->get<DeclArgumentPack *>()->size();
         
         continue;