From: Craig Topper Date: Fri, 5 Jul 2013 19:34:19 +0000 (+0000) Subject: Use SmallVectorImpl& for function arguments instead of SmallVector. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b9240e058bf3451685df73fc8ce181b3046e92b;p=clang Use SmallVectorImpl& for function arguments instead of SmallVector. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185715 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Types.h b/include/clang/Driver/Types.h index 18cd2d5102..be5015e843 100644 --- a/include/clang/Driver/Types.h +++ b/include/clang/Driver/Types.h @@ -78,7 +78,7 @@ namespace types { /// done for type 'Id'. void getCompilationPhases( ID Id, - llvm::SmallVector &Phases); + llvm::SmallVectorImpl &Phases); /// lookupCXXTypeForCType - Lookup CXX input type that corresponds to given /// C type (used for clang++ emulation of g++ behaviour) diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 6020136815..b376597e1b 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -2044,11 +2044,11 @@ private: bool isFunctionDeclaratorIdentifierList(); void ParseFunctionDeclaratorIdentifierList( Declarator &D, - SmallVector &ParamInfo); + SmallVectorImpl &ParamInfo); void ParseParameterDeclarationClause( Declarator &D, ParsedAttributes &attrs, - SmallVector &ParamInfo, + SmallVectorImpl &ParamInfo, SourceLocation &EllipsisLoc); void ParseBracketDeclarator(Declarator &D); diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 2d55c681a6..ef74abe188 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -1997,7 +1997,7 @@ public: /// \brief Return a source range list of C++11 attributes associated /// with the declarator. - void getCXX11AttributeRanges(SmallVector &Ranges) { + void getCXX11AttributeRanges(SmallVectorImpl &Ranges) { AttributeList *AttrList = Attrs.getList(); while (AttrList) { if (AttrList->isCXX11Attribute()) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 08c8ade33b..cdf24fc7df 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -993,7 +993,7 @@ public: sema::CapturedRegionScopeInfo *getCurCapturedRegion(); /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls - SmallVector &WeakTopLevelDecls() { return WeakTopLevelDecl; } + SmallVectorImpl &WeakTopLevelDecls() { return WeakTopLevelDecl; } void ActOnComment(SourceRange Comment); @@ -6859,7 +6859,7 @@ public: const FunctionProtoType *Proto, unsigned FirstProtoArg, ArrayRef Args, - SmallVector &AllArgs, + SmallVectorImpl &AllArgs, VariadicCallType CallType = VariadicDoesNotApply, bool AllowExplicit = false, bool IsListInitialization = false); diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 3861b8f67c..746850f40d 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1732,7 +1732,7 @@ public: /// \brief Read a template argument array. void - ReadTemplateArgumentList(SmallVector &TemplArgs, + ReadTemplateArgumentList(SmallVectorImpl &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx); diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index e0f552ba67..9a7a2f6f70 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -990,7 +990,7 @@ class TemplateDiff { /// makeTemplateList - Dump every template alias into the vector. static void makeTemplateList( - SmallVector &TemplateList, + SmallVectorImpl &TemplateList, const TemplateSpecializationType *TST) { while (TST) { TemplateList.push_back(TST); diff --git a/lib/AST/VTableBuilder.cpp b/lib/AST/VTableBuilder.cpp index 6c968bfe61..69a70a1760 100644 --- a/lib/AST/VTableBuilder.cpp +++ b/lib/AST/VTableBuilder.cpp @@ -1068,8 +1068,8 @@ void VTableBuilder::AddThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk) { assert(!isBuildingConstructorVTable() && "Can't add thunks for construction vtable"); - SmallVector &ThunksVector = Thunks[MD]; - + SmallVectorImpl &ThunksVector = Thunks[MD]; + // Check if we have this thunk already. if (std::find(ThunksVector.begin(), ThunksVector.end(), Thunk) != ThunksVector.end()) diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 7d6077396a..9ed50ec67d 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -2178,7 +2178,7 @@ static void checkArgMatches(llvm::Value *Elt, unsigned &ArgNo, } void CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV, - SmallVector &Args, + SmallVectorImpl &Args, llvm::FunctionType *IRFuncTy) { if (const ConstantArrayType *AT = getContext().getAsConstantArrayType(Ty)) { unsigned NumElts = AT->getSize().getZExtValue(); diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 83989697ad..419075fe17 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2332,7 +2332,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, static llvm::Constant *GenerateConstantVector(CGBuilderTy &Builder, - SmallVector &Elts) { + SmallVectorImpl &Elts) { SmallVector CElts; for (unsigned i = 0, e = Elts.size(); i != e; ++i) CElts.push_back(Builder.getInt32(Elts[i])); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index a9ed49ef73..1b62048b31 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -2469,7 +2469,7 @@ private: /// Ty, into individual arguments on the provided vector \arg Args. See /// ABIArgInfo::Expand. void ExpandTypeToArgs(QualType Ty, RValue Src, - SmallVector &Args, + SmallVectorImpl &Args, llvm::FunctionType *IRFuncTy); llvm::Value* EmitAsmInput(const TargetInfo::ConstraintInfo &Info, diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index fa9735705e..5d6a29b0d5 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -4699,7 +4699,7 @@ class MipsABIInfo : public ABIInfo { bool IsO32; unsigned MinABIStackAlignInBytes, StackAlignInBytes; void CoerceToIntArgs(uint64_t TySize, - SmallVector &ArgList) const; + SmallVectorImpl &ArgList) const; llvm::Type* HandleAggregates(QualType Ty, uint64_t TySize) const; llvm::Type* returnAggregateInRegs(QualType RetTy, uint64_t Size) const; llvm::Type* getPaddingType(uint64_t Align, uint64_t Offset) const; @@ -4749,7 +4749,7 @@ public: } void MipsABIInfo::CoerceToIntArgs(uint64_t TySize, - SmallVector &ArgList) const { + SmallVectorImpl &ArgList) const { llvm::IntegerType *IntTy = llvm::IntegerType::get(getVMContext(), MinABIStackAlignInBytes * 8); diff --git a/lib/Driver/Types.cpp b/lib/Driver/Types.cpp index 7d22596a17..87c695f133 100644 --- a/lib/Driver/Types.cpp +++ b/lib/Driver/Types.cpp @@ -180,9 +180,7 @@ types::ID types::lookupTypeForTypeSpecifier(const char *Name) { } // FIXME: Why don't we just put this list in the defs file, eh. -void types::getCompilationPhases( - ID Id, - llvm::SmallVector &P) { +void types::getCompilationPhases(ID Id, llvm::SmallVectorImpl &P) { if (Id != TY_Object) { if (getPreprocessedType(Id) != TY_INVALID) { P.push_back(phases::Preprocess); diff --git a/lib/Frontend/ChainedIncludesSource.cpp b/lib/Frontend/ChainedIncludesSource.cpp index cde84caade..442177ec31 100644 --- a/lib/Frontend/ChainedIncludesSource.cpp +++ b/lib/Frontend/ChainedIncludesSource.cpp @@ -26,9 +26,9 @@ using namespace clang; static ASTReader *createASTReader(CompilerInstance &CI, - StringRef pchFile, - SmallVector &memBufs, - SmallVector &bufNames, + StringRef pchFile, + SmallVectorImpl &memBufs, + SmallVectorImpl &bufNames, ASTDeserializationListener *deserialListener = 0) { Preprocessor &PP = CI.getPreprocessor(); OwningPtr Reader; diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 4f21995391..ded2b561a2 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -121,7 +121,7 @@ void TokenLexer::destroy() { /// Remove comma ahead of __VA_ARGS__, if present, according to compiler dialect /// settings. Returns true if the comma is removed. -static bool MaybeRemoveCommaBeforeVaArgs(SmallVector &ResultToks, +static bool MaybeRemoveCommaBeforeVaArgs(SmallVectorImpl &ResultToks, bool &NextTokGetsSpace, bool HasPasteOperator, MacroInfo *Macro, unsigned MacroArgNo, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index b3e2a85965..681468ddc7 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -5118,7 +5118,7 @@ bool Parser::isFunctionDeclaratorIdentifierList() { /// void Parser::ParseFunctionDeclaratorIdentifierList( Declarator &D, - SmallVector &ParamInfo) { + SmallVectorImpl &ParamInfo) { // If there was no identifier specified for the declarator, either we are in // an abstract-declarator, or we are in a parameter declarator which was found // to be abstract. In abstract-declarators, identifier lists are not valid: @@ -5199,7 +5199,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList( void Parser::ParseParameterDeclarationClause( Declarator &D, ParsedAttributes &FirstArgAttrs, - SmallVector &ParamInfo, + SmallVectorImpl &ParamInfo, SourceLocation &EllipsisLoc) { while (1) { diff --git a/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/lib/Rewrite/Frontend/RewriteModernObjC.cpp index fd1f26347a..546f9217ae 100644 --- a/lib/Rewrite/Frontend/RewriteModernObjC.cpp +++ b/lib/Rewrite/Frontend/RewriteModernObjC.cpp @@ -307,7 +307,7 @@ namespace { void ConvertSourceLocationToLineDirective(SourceLocation Loc, std::string &LineString); void RewriteForwardClassDecl(DeclGroupRef D); - void RewriteForwardClassDecl(const SmallVector &DG); + void RewriteForwardClassDecl(const SmallVectorImpl &DG); void RewriteForwardClassEpilogue(ObjCInterfaceDecl *ClassDecl, const std::string &typedefString); void RewriteImplementations(); @@ -325,7 +325,7 @@ namespace { void RewriteCategoryDecl(ObjCCategoryDecl *Dcl); void RewriteProtocolDecl(ObjCProtocolDecl *Dcl); void RewriteForwardProtocolDecl(DeclGroupRef D); - void RewriteForwardProtocolDecl(const SmallVector &DG); + void RewriteForwardProtocolDecl(const SmallVectorImpl &DG); void RewriteMethodDeclaration(ObjCMethodDecl *Method); void RewriteProperty(ObjCPropertyDecl *prop); void RewriteFunctionDecl(FunctionDecl *FD); @@ -478,7 +478,7 @@ namespace { StringRef FunName); FunctionDecl *SynthBlockInitFunctionDecl(StringRef name); Stmt *SynthBlockInitExpr(BlockExpr *Exp, - const SmallVector &InnerBlockDeclRefs); + const SmallVectorImpl &InnerBlockDeclRefs); // Misc. helper routines. QualType getProtocolType(); @@ -490,8 +490,8 @@ namespace { bool IsDeclStmtInForeachHeader(DeclStmt *DS); void CollectBlockDeclRefInfo(BlockExpr *Exp); void GetBlockDeclRefExprs(Stmt *S); - void GetInnerBlockDeclRefExprs(Stmt *S, - SmallVector &InnerBlockDeclRefs, + void GetInnerBlockDeclRefExprs(Stmt *S, + SmallVectorImpl &InnerBlockDeclRefs, llvm::SmallPtrSet &InnerContexts); // We avoid calling Type::isBlockPointerType(), since it operates on the @@ -1084,7 +1084,7 @@ void RewriteModernObjC::RewriteForwardClassDecl(DeclGroupRef D) { } void RewriteModernObjC::RewriteForwardClassDecl( - const SmallVector &D) { + const SmallVectorImpl &D) { std::string typedefString; for (unsigned i = 0; i < D.size(); i++) { ObjCInterfaceDecl *ForwardDecl = cast(D[i]); @@ -1202,7 +1202,7 @@ void RewriteModernObjC::RewriteForwardProtocolDecl(DeclGroupRef D) { } void -RewriteModernObjC::RewriteForwardProtocolDecl(const SmallVector &DG) { +RewriteModernObjC::RewriteForwardProtocolDecl(const SmallVectorImpl &DG) { SourceLocation LocStart = DG[0]->getLocStart(); if (LocStart.isInvalid()) llvm_unreachable("Invalid SourceLocation"); @@ -4662,8 +4662,8 @@ void RewriteModernObjC::GetBlockDeclRefExprs(Stmt *S) { return; } -void RewriteModernObjC::GetInnerBlockDeclRefExprs(Stmt *S, - SmallVector &InnerBlockDeclRefs, +void RewriteModernObjC::GetInnerBlockDeclRefExprs(Stmt *S, + SmallVectorImpl &InnerBlockDeclRefs, llvm::SmallPtrSet &InnerContexts) { for (Stmt::child_range CI = S->children(); CI; ++CI) if (*CI) { @@ -5407,7 +5407,7 @@ FunctionDecl *RewriteModernObjC::SynthBlockInitFunctionDecl(StringRef name) { } Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, - const SmallVector &InnerBlockDeclRefs) { + const SmallVectorImpl &InnerBlockDeclRefs) { const BlockDecl *block = Exp->getBlockDecl(); diff --git a/lib/Rewrite/Frontend/RewriteObjC.cpp b/lib/Rewrite/Frontend/RewriteObjC.cpp index 662efaa63a..316009fc51 100644 --- a/lib/Rewrite/Frontend/RewriteObjC.cpp +++ b/lib/Rewrite/Frontend/RewriteObjC.cpp @@ -267,7 +267,7 @@ namespace { void RewriteRecordBody(RecordDecl *RD); void RewriteInclude(); void RewriteForwardClassDecl(DeclGroupRef D); - void RewriteForwardClassDecl(const SmallVector &DG); + void RewriteForwardClassDecl(const SmallVectorImpl &DG); void RewriteForwardClassEpilogue(ObjCInterfaceDecl *ClassDecl, const std::string &typedefString); void RewriteImplementations(); @@ -285,7 +285,7 @@ namespace { void RewriteCategoryDecl(ObjCCategoryDecl *Dcl); void RewriteProtocolDecl(ObjCProtocolDecl *Dcl); void RewriteForwardProtocolDecl(DeclGroupRef D); - void RewriteForwardProtocolDecl(const SmallVector &DG); + void RewriteForwardProtocolDecl(const SmallVectorImpl &DG); void RewriteMethodDeclaration(ObjCMethodDecl *Method); void RewriteProperty(ObjCPropertyDecl *prop); void RewriteFunctionDecl(FunctionDecl *FD); @@ -395,7 +395,7 @@ namespace { StringRef FunName); FunctionDecl *SynthBlockInitFunctionDecl(StringRef name); Stmt *SynthBlockInitExpr(BlockExpr *Exp, - const SmallVector &InnerBlockDeclRefs); + const SmallVectorImpl &InnerBlockDeclRefs); // Misc. helper routines. QualType getProtocolType(); @@ -408,8 +408,8 @@ namespace { bool IsDeclStmtInForeachHeader(DeclStmt *DS); void CollectBlockDeclRefInfo(BlockExpr *Exp); void GetBlockDeclRefExprs(Stmt *S); - void GetInnerBlockDeclRefExprs(Stmt *S, - SmallVector &InnerBlockDeclRefs, + void GetInnerBlockDeclRefExprs(Stmt *S, + SmallVectorImpl &InnerBlockDeclRefs, llvm::SmallPtrSet &InnerContexts); // We avoid calling Type::isBlockPointerType(), since it operates on the @@ -926,7 +926,7 @@ void RewriteObjC::RewriteForwardClassDecl(DeclGroupRef D) { RewriteForwardClassEpilogue(cast(*I), typedefString); } -void RewriteObjC::RewriteForwardClassDecl(const SmallVector &D) { +void RewriteObjC::RewriteForwardClassDecl(const SmallVectorImpl &D) { std::string typedefString; for (unsigned i = 0; i < D.size(); i++) { ObjCInterfaceDecl *ForwardDecl = cast(D[i]); @@ -1038,7 +1038,7 @@ void RewriteObjC::RewriteForwardProtocolDecl(DeclGroupRef D) { } void -RewriteObjC::RewriteForwardProtocolDecl(const SmallVector &DG) { +RewriteObjC::RewriteForwardProtocolDecl(const SmallVectorImpl &DG) { SourceLocation LocStart = DG[0]->getLocStart(); if (LocStart.isInvalid()) llvm_unreachable("Invalid SourceLocation"); @@ -3743,8 +3743,8 @@ void RewriteObjC::GetBlockDeclRefExprs(Stmt *S) { return; } -void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S, - SmallVector &InnerBlockDeclRefs, +void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S, + SmallVectorImpl &InnerBlockDeclRefs, llvm::SmallPtrSet &InnerContexts) { for (Stmt::child_range CI = S->children(); CI; ++CI) if (*CI) { @@ -4452,7 +4452,7 @@ FunctionDecl *RewriteObjC::SynthBlockInitFunctionDecl(StringRef name) { } Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, - const SmallVector &InnerBlockDeclRefs) { + const SmallVectorImpl &InnerBlockDeclRefs) { const BlockDecl *block = Exp->getBlockDecl(); Blocks.push_back(Exp); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 8e6b1bd287..d20023d13a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3309,11 +3309,11 @@ static bool CheckAnonMemberRedeclaration(Sema &SemaRef, /// This routine is recursive, injecting the names of nested anonymous /// structs/unions into the owning context and scope as well. static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, - DeclContext *Owner, - RecordDecl *AnonRecord, - AccessSpecifier AS, - SmallVector &Chaining, - bool MSAnonStruct) { + DeclContext *Owner, + RecordDecl *AnonRecord, + AccessSpecifier AS, + SmallVectorImpl &Chaining, + bool MSAnonStruct) { unsigned diagKind = AnonRecord->isUnion() ? diag::err_anonymous_union_member_redecl : diag::err_anonymous_struct_member_redecl; diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 2aab22c9cf..4c18a33061 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -682,7 +682,7 @@ static void handleNoSanitizeThread(Sema &S, Decl *D, static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, - SmallVector &Args) { + SmallVectorImpl &Args) { assert(!Attr.isInvalid()); if (!checkAttributeAtLeastNumArgs(S, Attr, 1)) @@ -743,7 +743,7 @@ static void handleAcquiredBeforeAttr(Sema &S, Decl *D, static bool checkLockFunAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, - SmallVector &Args) { + SmallVectorImpl &Args) { assert(!Attr.isInvalid()); // zero or more arguments ok @@ -818,7 +818,7 @@ static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, - SmallVector &Args) { + SmallVectorImpl &Args) { assert(!Attr.isInvalid()); if (!checkAttributeAtLeastNumArgs(S, Attr, 1)) @@ -872,7 +872,7 @@ static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, static bool checkLocksRequiredCommon(Sema &S, Decl *D, const AttributeList &Attr, - SmallVector &Args) { + SmallVectorImpl &Args) { assert(!Attr.isInvalid()); if (!checkAttributeAtLeastNumArgs(S, Attr, 1)) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 40aeefbf97..c35c1b4e64 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3919,7 +3919,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, const FunctionProtoType *Proto, unsigned FirstProtoArg, ArrayRef Args, - SmallVector &AllArgs, + SmallVectorImpl &AllArgs, VariadicCallType CallType, bool AllowExplicit, bool IsListInitialization) { diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 8c8831a14b..e2a57f3829 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -6922,7 +6922,7 @@ ASTReader::ReadTemplateParameterList(ModuleFile &F, void ASTReader:: -ReadTemplateArgumentList(SmallVector &TemplArgs, +ReadTemplateArgumentList(SmallVectorImpl &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx) { unsigned NumTemplateArgs = Record[Idx++];