[cfe-commits] r125769 - in /cfe/trunk/lib/Sema: SemaTemplateInstantiate.cpp SemaTemplateVariadic.cpp
Chris Lattner
sabre at nondot.org
Thu Feb 17 11:38:27 PST 2011
Author: lattner
Date: Thu Feb 17 13:38:27 2011
New Revision: 125769
URL: http://llvm.org/viewvc/llvm-project?rev=125769&view=rev
Log:
remove some defensive code: LocalInstantiationScope::getInstantiationOf
and findInstantiationOf can never return null, even on invalid code.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=125769&r1=125768&r2=125769&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Feb 17 13:38:27 2011
@@ -2168,8 +2168,7 @@
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 @@
break;
}
- assert(D->isInvalidDecl() &&
- "declaration was not instantiated in this scope!");
+ assert(0 && "declaration was not instantiated in this scope!");
return 0;
}
Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=125769&r1=125768&r2=125769&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Thu Feb 17 13:38:27 2011
@@ -503,8 +503,7 @@
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 @@
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;
More information about the cfe-commits
mailing list