Reduce the amount of stack space we use in SmallVectors during

template instantiation. This helps reduce our stack footprint when
performing deep template instantiations.

llvm-svn: 72582
This commit is contained in:
Douglas Gregor 2009-05-29 18:27:38 +00:00
parent 893abe482d
commit 6181ded4ad
4 changed files with 13 additions and 13 deletions

View File

@ -378,7 +378,7 @@ InstantiateFunctionProtoType(const FunctionProtoType *T,
if (ResultType.isNull())
return ResultType;
llvm::SmallVector<QualType, 16> ParamTypes;
llvm::SmallVector<QualType, 4> ParamTypes;
for (FunctionProtoType::arg_type_iterator Param = T->arg_type_begin(),
ParamEnd = T->arg_type_end();
Param != ParamEnd; ++Param) {
@ -497,7 +497,7 @@ TemplateTypeInstantiator::
InstantiateTemplateSpecializationType(
const TemplateSpecializationType *T,
unsigned Quals) const {
llvm::SmallVector<TemplateArgument, 16> InstantiatedTemplateArgs;
llvm::SmallVector<TemplateArgument, 4> InstantiatedTemplateArgs;
InstantiatedTemplateArgs.reserve(T->getNumArgs());
for (TemplateSpecializationType::iterator Arg = T->begin(), ArgEnd = T->end();
Arg != ArgEnd; ++Arg) {
@ -669,7 +669,7 @@ Sema::InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
const TemplateArgumentList &TemplateArgs) {
bool Invalid = false;
llvm::SmallVector<CXXBaseSpecifier*, 8> InstantiatedBases;
llvm::SmallVector<CXXBaseSpecifier*, 4> InstantiatedBases;
for (ClassTemplateSpecializationDecl::base_class_iterator
Base = Pattern->bases_begin(), BaseEnd = Pattern->bases_end();
Base != BaseEnd; ++Base) {
@ -767,7 +767,7 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
if (InstantiateBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
Invalid = true;
llvm::SmallVector<DeclPtrTy, 32> Fields;
llvm::SmallVector<DeclPtrTy, 4> Fields;
for (RecordDecl::decl_iterator Member = Pattern->decls_begin(Context),
MemberEnd = Pattern->decls_end(Context);
Member != MemberEnd; ++Member) {

View File

@ -214,7 +214,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
Owner->addDecl(SemaRef.Context, Enum);
Enum->startDefinition();
llvm::SmallVector<Sema::DeclPtrTy, 16> Enumerators;
llvm::SmallVector<Sema::DeclPtrTy, 4> Enumerators;
EnumConstantDecl *LastEnumConst = 0;
for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(SemaRef.Context),
@ -288,7 +288,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) {
Sema::LocalInstantiationScope Scope(SemaRef);
llvm::SmallVector<ParmVarDecl *, 16> Params;
llvm::SmallVector<ParmVarDecl *, 4> Params;
QualType T = InstantiateFunctionType(D, Params);
if (T.isNull())
return 0;
@ -331,7 +331,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) {
Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
Sema::LocalInstantiationScope Scope(SemaRef);
llvm::SmallVector<ParmVarDecl *, 16> Params;
llvm::SmallVector<ParmVarDecl *, 4> Params;
QualType T = InstantiateFunctionType(D, Params);
if (T.isNull())
return 0;
@ -378,7 +378,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
Sema::LocalInstantiationScope Scope(SemaRef);
llvm::SmallVector<ParmVarDecl *, 16> Params;
llvm::SmallVector<ParmVarDecl *, 4> Params;
QualType T = InstantiateFunctionType(D, Params);
if (T.isNull())
return 0;
@ -409,7 +409,7 @@ Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
Sema::LocalInstantiationScope Scope(SemaRef);
llvm::SmallVector<ParmVarDecl *, 16> Params;
llvm::SmallVector<ParmVarDecl *, 4> Params;
QualType T = InstantiateFunctionType(D, Params);
if (T.isNull())
return 0;
@ -505,7 +505,7 @@ TemplateDeclInstantiator::InstantiateFunctionType(FunctionDecl *D,
// Instantiate the function parameters
TemplateDeclInstantiator ParamInstantiator(SemaRef, 0, TemplateArgs);
llvm::SmallVector<QualType, 16> ParamTys;
llvm::SmallVector<QualType, 4> ParamTys;
for (FunctionDecl::param_iterator P = D->param_begin(),
PEnd = D->param_end();
P != PEnd; ++P) {

View File

@ -575,7 +575,7 @@ Sema::OwningExprResult TemplateExprInstantiator::VisitVAArgExpr(VAArgExpr *E) {
Sema::OwningExprResult
TemplateExprInstantiator::VisitInitListExpr(InitListExpr *E) {
ExprVector Inits(SemaRef);
ASTOwningVector<&ActionBase::DeleteExpr, 4> Inits(SemaRef);
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) {
OwningExprResult Init = Visit(E->getInit(I));
if (Init.isInvalid())
@ -597,7 +597,7 @@ TemplateExprInstantiator::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
return SemaRef.ExprError();
// Instantiate the designators.
ExprVector ArrayExprs(SemaRef); // Expresses used in array designators
ASTOwningVector<&ActionBase::DeleteExpr, 4> ArrayExprs(SemaRef);
for (DesignatedInitExpr::designators_iterator D = E->designators_begin(),
DEnd = E->designators_end();
D != DEnd; ++D) {

View File

@ -60,7 +60,7 @@ namespace {
// Common/C statements
//===----------------------------------------------------------------------===/
Sema::OwningStmtResult TemplateStmtInstantiator::VisitDeclStmt(DeclStmt *S) {
llvm::SmallVector<Decl *, 8> Decls;
llvm::SmallVector<Decl *, 4> Decls;
for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
D != DEnd; ++D) {
Decl *Instantiated = SemaRef.InstantiateDecl(*D, SemaRef.CurContext,