diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index dbb44dfbc2410ba59ffc581d91e5aafc391ccafe..cd7d2538a1fd863c788d830d4ed9254b75b046bc 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -1952,29 +1952,24 @@ public: unsigned getBuiltinID() const; - // Iterator access to formal parameters. - unsigned param_size() const { return getNumParams(); } - typedef ParmVarDecl **param_iterator; - typedef ParmVarDecl * const *param_const_iterator; - typedef llvm::iterator_range<param_iterator> param_range; - typedef llvm::iterator_range<param_const_iterator> param_const_range; - - param_iterator param_begin() { return param_iterator(ParamInfo); } - param_iterator param_end() { - return param_iterator(ParamInfo + param_size()); - } - param_range params() { return param_range(param_begin(), param_end()); } - - param_const_iterator param_begin() const { - return param_const_iterator(ParamInfo); - } - param_const_iterator param_end() const { - return param_const_iterator(ParamInfo + param_size()); + // ArrayRef interface to parameters. + ArrayRef<ParmVarDecl *> parameters() const { + return {ParamInfo, getNumParams()}; } - param_const_range params() const { - return param_const_range(param_begin(), param_end()); + MutableArrayRef<ParmVarDecl *> parameters() { + return {ParamInfo, getNumParams()}; } + // Iterator access to formal parameters. + typedef MutableArrayRef<ParmVarDecl *>::iterator param_iterator; + typedef ArrayRef<ParmVarDecl *>::const_iterator param_const_iterator; + bool param_empty() const { return parameters().empty(); } + param_iterator param_begin() { return parameters().begin(); } + param_iterator param_end() { return parameters().end(); } + param_const_iterator param_begin() const { return parameters().begin(); } + param_const_iterator param_end() const { return parameters().end(); } + size_t param_size() const { return parameters().size(); } + /// getNumParams - Return the number of parameters this function must have /// based on its FunctionType. This is the length of the ParamInfo array /// after it has been created. @@ -1992,12 +1987,6 @@ public: setParams(getASTContext(), NewParamInfo); } - // ArrayRef iterface to parameters. - // FIXME: Should one day replace iterator interface. - ArrayRef<ParmVarDecl*> parameters() const { - return llvm::makeArrayRef(ParamInfo, getNumParams()); - } - ArrayRef<NamedDecl *> getDeclsInPrototypeScope() const { return DeclsInPrototypeScope; } @@ -2504,34 +2493,33 @@ class IndirectFieldDecl : public ValueDecl, IndirectFieldDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, - NamedDecl **CH, unsigned CHS); + MutableArrayRef<NamedDecl *> CH); public: static IndirectFieldDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - QualType T, NamedDecl **CH, unsigned CHS); + QualType T, llvm::MutableArrayRef<NamedDecl *> CH); static IndirectFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); - - typedef NamedDecl * const *chain_iterator; - typedef llvm::iterator_range<chain_iterator> chain_range; - chain_range chain() const { return chain_range(chain_begin(), chain_end()); } - chain_iterator chain_begin() const { return chain_iterator(Chaining); } - chain_iterator chain_end() const { - return chain_iterator(Chaining + ChainingSize); + typedef ArrayRef<NamedDecl *>::const_iterator chain_iterator; + + ArrayRef<NamedDecl *> chain() const { + return llvm::makeArrayRef(Chaining, ChainingSize); } + chain_iterator chain_begin() const { return chain().begin(); } + chain_iterator chain_end() const { return chain().end(); } unsigned getChainingSize() const { return ChainingSize; } FieldDecl *getAnonField() const { - assert(ChainingSize >= 2); - return cast<FieldDecl>(Chaining[ChainingSize - 1]); + assert(chain().size() >= 2); + return cast<FieldDecl>(chain().back()); } VarDecl *getVarDecl() const { - assert(ChainingSize >= 2); - return dyn_cast<VarDecl>(*chain_begin()); + assert(chain().size() >= 2); + return dyn_cast<VarDecl>(chain().front()); } IndirectFieldDecl *getCanonicalDecl() override { return getFirstDecl(); } @@ -3518,35 +3506,23 @@ public: void setSignatureAsWritten(TypeSourceInfo *Sig) { SignatureAsWritten = Sig; } TypeSourceInfo *getSignatureAsWritten() const { return SignatureAsWritten; } - // Iterator access to formal parameters. - unsigned param_size() const { return getNumParams(); } - typedef ParmVarDecl **param_iterator; - typedef ParmVarDecl * const *param_const_iterator; - typedef llvm::iterator_range<param_iterator> param_range; - typedef llvm::iterator_range<param_const_iterator> param_const_range; - // ArrayRef access to formal parameters. - // FIXME: Should eventual replace iterator access. - ArrayRef<ParmVarDecl*> parameters() const { - return llvm::makeArrayRef(ParamInfo, param_size()); + ArrayRef<ParmVarDecl *> parameters() const { + return {ParamInfo, getNumParams()}; } - - bool param_empty() const { return NumParams == 0; } - param_range params() { return param_range(param_begin(), param_end()); } - param_iterator param_begin() { return param_iterator(ParamInfo); } - param_iterator param_end() { - return param_iterator(ParamInfo + param_size()); + MutableArrayRef<ParmVarDecl *> parameters() { + return {ParamInfo, getNumParams()}; } - param_const_range params() const { - return param_const_range(param_begin(), param_end()); - } - param_const_iterator param_begin() const { - return param_const_iterator(ParamInfo); - } - param_const_iterator param_end() const { - return param_const_iterator(ParamInfo + param_size()); - } + // Iterator access to formal parameters. + typedef MutableArrayRef<ParmVarDecl *>::iterator param_iterator; + typedef ArrayRef<ParmVarDecl *>::const_iterator param_const_iterator; + bool param_empty() const { return parameters().empty(); } + param_iterator param_begin() { return parameters().begin(); } + param_iterator param_end() { return parameters().end(); } + param_const_iterator param_begin() const { return parameters().begin(); } + param_const_iterator param_end() const { return parameters().end(); } + size_t param_size() const { return parameters().size(); } unsigned getNumParams() const { return NumParams; } const ParmVarDecl *getParamDecl(unsigned i) const { @@ -3567,22 +3543,12 @@ public: /// Does not include an entry for 'this'. unsigned getNumCaptures() const { return NumCaptures; } - typedef const Capture *capture_iterator; - typedef const Capture *capture_const_iterator; - typedef llvm::iterator_range<capture_iterator> capture_range; - typedef llvm::iterator_range<capture_const_iterator> capture_const_range; + typedef ArrayRef<Capture>::const_iterator capture_const_iterator; - capture_range captures() { - return capture_range(capture_begin(), capture_end()); - } - capture_const_range captures() const { - return capture_const_range(capture_begin(), capture_end()); - } + ArrayRef<Capture> captures() const { return {Captures, NumCaptures}; } - capture_iterator capture_begin() { return Captures; } - capture_iterator capture_end() { return Captures + NumCaptures; } - capture_const_iterator capture_begin() const { return Captures; } - capture_const_iterator capture_end() const { return Captures + NumCaptures; } + capture_const_iterator capture_begin() const { return captures().begin(); } + capture_const_iterator capture_end() const { return captures().end(); } bool capturesCXXThis() const { return CapturesCXXThis; } bool blockMissingReturnType() const { return BlockMissingReturnType; } @@ -3693,9 +3659,6 @@ public: /// \brief Retrieve an iterator one past the last parameter decl. param_iterator param_end() const { return getParams() + NumParams; } - /// \brief Retrieve an iterator range for the parameter declarations. - param_range params() const { return param_range(param_begin(), param_end()); } - // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == Captured; } diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index f89717f698a5c18c9bbbbfd3c50f490400b2c40e..4e9682f3b32e409f96ce61b831c19ef1b4267741 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -351,11 +351,6 @@ public: typedef llvm::iterator_range<param_iterator> param_range; typedef llvm::iterator_range<param_const_iterator> param_const_range; - param_range params() { return param_range(param_begin(), param_end()); } - param_const_range params() const { - return param_const_range(param_begin(), param_end()); - } - param_const_iterator param_begin() const { return param_const_iterator(getParams()); } diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 7063c6f706507787ef16906625b8370c65226938..5586298815fc1066b5b2e45c9ed588d8eff01bf7 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1827,16 +1827,14 @@ public: /// \brief Diagnose any unused parameters in the given sequence of /// ParmVarDecl pointers. - void DiagnoseUnusedParameters(ParmVarDecl * const *Begin, - ParmVarDecl * const *End); + void DiagnoseUnusedParameters(ArrayRef<ParmVarDecl *> Parameters); /// \brief Diagnose whether the size of parameters or return value of a /// function or obj-c method definition is pass-by-value and larger than a /// specified threshold. - void DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl * const *Begin, - ParmVarDecl * const *End, - QualType ReturnTy, - NamedDecl *D); + void + DiagnoseSizeOfParametersAndReturnValue(ArrayRef<ParmVarDecl *> Parameters, + QualType ReturnTy, NamedDecl *D); void DiagnoseInvalidJumps(Stmt *Body); Decl *ActOnFileScopeAsmDecl(Expr *expr, @@ -2665,8 +2663,7 @@ public: CallExpr *CE, FunctionDecl *FD); /// Helpers for dealing with blocks and functions. - bool CheckParmsForFunctionDef(ParmVarDecl *const *Param, - ParmVarDecl *const *ParamEnd, + bool CheckParmsForFunctionDef(ArrayRef<ParmVarDecl *> Parameters, bool CheckParameterNames); void CheckCXXDefaultArguments(FunctionDecl *FD); void CheckExtraCXXDefaultArguments(Declarator &D); @@ -7140,8 +7137,7 @@ public: int indexAdjustment, Optional<unsigned> NumExpansions, bool ExpectParameterPack); - bool SubstParmTypes(SourceLocation Loc, - ParmVarDecl **Params, unsigned NumParams, + bool SubstParmTypes(SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl<QualType> &ParamTypes, diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 5fc7877322cd3591e61a956211cba911a4685686..572cebc68148d19a9ee38b379d8300b2c04ecb96 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -5164,7 +5164,7 @@ std::string ASTContext::getObjCEncodingForBlock(const BlockExpr *Expr) const { SourceLocation Loc; CharUnits PtrSize = getTypeSizeInChars(VoidPtrTy); CharUnits ParmOffset = PtrSize; - for (auto PI : Decl->params()) { + for (auto PI : Decl->parameters()) { QualType PType = PI->getType(); CharUnits sz = getObjCEncodingTypeSize(PType); if (sz.isZero()) @@ -5179,7 +5179,7 @@ std::string ASTContext::getObjCEncodingForBlock(const BlockExpr *Expr) const { // Argument types. ParmOffset = PtrSize; - for (auto PVDecl : Decl->params()) { + for (auto PVDecl : Decl->parameters()) { QualType PType = PVDecl->getOriginalType(); if (const ArrayType *AT = dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) { @@ -5207,7 +5207,7 @@ bool ASTContext::getObjCEncodingForFunctionDecl(const FunctionDecl *Decl, getObjCEncodingForType(Decl->getReturnType(), S); CharUnits ParmOffset; // Compute size of all parameters. - for (auto PI : Decl->params()) { + for (auto PI : Decl->parameters()) { QualType PType = PI->getType(); CharUnits sz = getObjCEncodingTypeSize(PType); if (sz.isZero()) @@ -5221,7 +5221,7 @@ bool ASTContext::getObjCEncodingForFunctionDecl(const FunctionDecl *Decl, ParmOffset = CharUnits::Zero(); // Argument types. - for (auto PVDecl : Decl->params()) { + for (auto PVDecl : Decl->parameters()) { QualType PType = PVDecl->getOriginalType(); if (const ArrayType *AT = dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) { diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index da7e980c5a4d3908d9e5239b1ed30231818fe857..e1d52eaf0d9522cb4785ebe67a51771ef1d8a1dd 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -1681,7 +1681,7 @@ void ASTDumper::VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) { } void ASTDumper::VisitBlockDecl(const BlockDecl *D) { - for (auto I : D->params()) + for (auto I : D->parameters()) dumpDecl(I); if (D->isVariadic()) diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 9a4e4a2894d2b67ca36c6a122afe434ff5e0678f..4f799264811553d53c79e794db9e185b89db38a9 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -3010,7 +3010,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { // Import the function parameters. SmallVector<ParmVarDecl *, 8> Parameters; - for (auto P : D->params()) { + for (auto P : D->parameters()) { ParmVarDecl *ToP = cast_or_null<ParmVarDecl>(Importer.Import(P)); if (!ToP) return nullptr; @@ -3276,7 +3276,7 @@ Decl *ASTNodeImporter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { IndirectFieldDecl *ToIndirectField = IndirectFieldDecl::Create( Importer.getToContext(), DC, Loc, Name.getAsIdentifierInfo(), T, - NamedChain, D->getChainingSize()); + {NamedChain, D->getChainingSize()}); for (const auto *Attr : D->attrs()) ToIndirectField->addAttr(Attr->clone(Importer.getToContext())); @@ -3619,7 +3619,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { // Import the parameters SmallVector<ParmVarDecl *, 5> ToParams; - for (auto *FromP : D->params()) { + for (auto *FromP : D->parameters()) { ParmVarDecl *ToP = cast_or_null<ParmVarDecl>(Importer.Import(FromP)); if (!ToP) return nullptr; diff --git a/lib/AST/Comment.cpp b/lib/AST/Comment.cpp index d05c5de543ffcc4922ed01cafbf8710e844a3efe..893bdc5c17bf88ef2848bd3a0f4de6fc33531406 100644 --- a/lib/AST/Comment.cpp +++ b/lib/AST/Comment.cpp @@ -157,7 +157,7 @@ void DeclInfo::fill() { case Decl::CXXConversion: { const FunctionDecl *FD = cast<FunctionDecl>(CommentDecl); Kind = FunctionKind; - ParamVars = llvm::makeArrayRef(FD->param_begin(), FD->getNumParams()); + ParamVars = FD->parameters(); ReturnType = FD->getReturnType(); unsigned NumLists = FD->getNumTemplateParameterLists(); if (NumLists != 0) { @@ -177,7 +177,7 @@ void DeclInfo::fill() { case Decl::ObjCMethod: { const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(CommentDecl); Kind = FunctionKind; - ParamVars = llvm::makeArrayRef(MD->param_begin(), MD->param_size()); + ParamVars = MD->parameters(); ReturnType = MD->getReturnType(); IsObjCMethod = true; IsInstanceMethod = MD->isInstanceMethod(); @@ -189,7 +189,7 @@ void DeclInfo::fill() { Kind = FunctionKind; TemplateKind = Template; const FunctionDecl *FD = FTD->getTemplatedDecl(); - ParamVars = llvm::makeArrayRef(FD->param_begin(), FD->getNumParams()); + ParamVars = FD->parameters(); ReturnType = FD->getReturnType(); TemplateParameters = FTD->getTemplateParameters(); break; diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 09ba90a3ea0dc28aa86eef9469cf60b0a4d843f4..d59c4b422b341284926ab0c2e51c5540c0d987ea 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2793,7 +2793,7 @@ unsigned FunctionDecl::getMinRequiredArguments() const { return getNumParams(); unsigned NumRequiredArgs = 0; - for (auto *Param : params()) + for (auto *Param : parameters()) if (!Param->isParameterPack() && !Param->hasDefaultArg()) ++NumRequiredArgs; return NumRequiredArgs; @@ -4099,8 +4099,10 @@ void IndirectFieldDecl::anchor() { } IndirectFieldDecl::IndirectFieldDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, - QualType T, NamedDecl **CH, unsigned CHS) - : ValueDecl(IndirectField, DC, L, N, T), Chaining(CH), ChainingSize(CHS) { + QualType T, + MutableArrayRef<NamedDecl *> CH) + : ValueDecl(IndirectField, DC, L, N, T), Chaining(CH.data()), + ChainingSize(CH.size()) { // In C++, indirect field declarations conflict with tag declarations in the // same scope, so add them to IDNS_Tag so that tag redeclaration finds them. if (C.getLangOpts().CPlusPlus) @@ -4109,16 +4111,15 @@ IndirectFieldDecl::IndirectFieldDecl(ASTContext &C, DeclContext *DC, IndirectFieldDecl * IndirectFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, - IdentifierInfo *Id, QualType T, NamedDecl **CH, - unsigned CHS) { - return new (C, DC) IndirectFieldDecl(C, DC, L, Id, T, CH, CHS); + IdentifierInfo *Id, QualType T, + llvm::MutableArrayRef<NamedDecl *> CH) { + return new (C, DC) IndirectFieldDecl(C, DC, L, Id, T, CH); } IndirectFieldDecl *IndirectFieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) IndirectFieldDecl(C, nullptr, SourceLocation(), - DeclarationName(), QualType(), nullptr, - 0); + DeclarationName(), QualType(), None); } SourceRange EnumConstantDecl::getSourceRange() const { diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 9d76f65b62a842cf2d208dd32d6d5712e0c23198..6868ea2a6d7d8b521810f5ac583d4297dca23f3d 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -1055,7 +1055,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) { std::string name = OMD->getSelector().getAsString(); std::string::size_type pos, lastPos = 0; - for (const auto *PI : OMD->params()) { + for (const auto *PI : OMD->parameters()) { // FIXME: selector is missing here! pos = name.find_first_of(':', lastPos); Out << " " << name.substr(lastPos, pos - lastPos) << ':'; diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index d5b7e108395245aa5a634cadda9808021a783218..311187b4b395b73ab8e85a08e98e3e51d855bfbd 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -2054,7 +2054,7 @@ void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) { OS << " ("; CXXMethodDecl *Method = Node->getCallOperator(); NeedComma = false; - for (auto P : Method->params()) { + for (auto P : Method->parameters()) { if (NeedComma) { OS << ", "; } else { diff --git a/lib/Analysis/Consumed.cpp b/lib/Analysis/Consumed.cpp index f2a7d904a54e41acd5c5950699f6ccff03d74853..47bef1b927c9e413d877cdf9acde0b7932aa1464 100644 --- a/lib/Analysis/Consumed.cpp +++ b/lib/Analysis/Consumed.cpp @@ -1362,7 +1362,7 @@ void ConsumedAnalyzer::run(AnalysisDeclContext &AC) { ConsumedStmtVisitor Visitor(AC, *this, CurrStates.get()); // Add all trackable parameters to the state map. - for (const auto *PI : D->params()) + for (const auto *PI : D->parameters()) Visitor.VisitParmVarDecl(PI); // Visit all of the function's basic blocks. diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index dec071440ad4d6b8778bf7f947d26818b0d32b22..c562602d96b7029a8ce457d7556685160b41cec5 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -402,7 +402,7 @@ CodeGenTypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD, argTys.push_back(Context.getCanonicalParamType(receiverType)); argTys.push_back(Context.getCanonicalParamType(Context.getObjCSelType())); // FIXME: Kill copy? - for (const auto *I : MD->params()) { + for (const auto *I : MD->parameters()) { argTys.push_back(Context.getCanonicalParamType(I->getType())); } diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 768c2030a6cc6afed393debd1338c56127091776..dc4455fbc7d234637e4ad0461c2a97ec74e13b59 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -2785,7 +2785,7 @@ void CodeGenFunction::EmitLambdaBlockInvokeBody() { CallArgs.add(RValue::get(ThisPtr.getPointer()), ThisType); // Add the rest of the parameters. - for (auto param : BD->params()) + for (auto param : BD->parameters()) EmitDelegateCallArg(CallArgs, param, param->getLocStart()); assert(!Lambda->isGenericLambda() && @@ -2815,7 +2815,7 @@ void CodeGenFunction::EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD) { CallArgs.add(RValue::get(ThisPtr), ThisType); // Add the rest of the parameters. - for (auto Param : MD->params()) + for (auto Param : MD->parameters()) EmitDelegateCallArg(CallArgs, Param, Param->getLocStart()); const CXXMethodDecl *CallOp = Lambda->getLambdaCallOperator(); diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 5448d7b1c5db50f3b90e650097861515711102b6..bfd9e8d3ba551df3c600774ad104d685f8d82d1f 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2766,7 +2766,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, Elts.push_back(DBuilder.createArtificialType( getOrCreateType(CGM.getContext().getObjCSelType(), F))); // Get rest of the arguments. - for (const auto *PI : OMethod->params()) + for (const auto *PI : OMethod->parameters()) Elts.push_back(getOrCreateType(PI->getType(), F)); // Variadic methods need a special marker at the end of the type list. if (OMethod->isVariadic()) diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 4f14f87275212f858cc4d60778632702e264217d..019cfc601fe8a4931e5d73c06740661396d4b700 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1943,7 +1943,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, // Emit a null-check if there's a consumed argument other than the receiver. bool RequiresNullCheck = false; if (ReceiverCanBeNull && CGM.getLangOpts().ObjCAutoRefCount && Method) { - for (const auto *ParamDecl : Method->params()) { + for (const auto *ParamDecl : Method->parameters()) { if (ParamDecl->hasAttr<NSConsumedAttr>()) { if (!nullReturn.NullBB) nullReturn.init(CGF, Arg0); @@ -6828,7 +6828,7 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF, bool requiresnullCheck = false; if (CGM.getLangOpts().ObjCAutoRefCount && method) - for (const auto *ParamDecl : method->params()) { + for (const auto *ParamDecl : method->parameters()) { if (ParamDecl->hasAttr<NSConsumedAttr>()) { if (!nullReturn.NullBB) nullReturn.init(CGF, arg0); diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index 059492665d7a64bf7d38969dd6fbd587aa01302a..6a0edbe0e7a92ecd2350fd29693fb7ac1159f63c 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -6405,7 +6405,7 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD, if (isa<CXXMethodDecl>(FD)) ParamPositions.insert({FD, 0}); unsigned ParamPos = ParamPositions.size(); - for (auto *P : FD->params()) { + for (auto *P : FD->parameters()) { ParamPositions.insert({P->getCanonicalDecl(), ParamPos}); ++ParamPos; } diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 38461446de585c82d2d06ac369028a6b42609fab..6f749056ad6ee5852aa933530f9303c891dca981 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -284,7 +284,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Value *Callee, CGM.getCXXABI().adjustCallArgsForDestructorThunk(*this, CurGD, CallArgs); // Add the rest of the arguments. - for (const ParmVarDecl *PD : MD->params()) + for (const ParmVarDecl *PD : MD->parameters()) EmitDelegateCallArg(CallArgs, PD, PD->getLocStart()); const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>(); diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 2dc4c12ce2e19a84ee7cc85feb24c738193e0365..e914d7935593fbaad174d13e286652f6ad340e98 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -949,7 +949,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, CGM.getCXXABI().buildThisParam(*this, Args); } - for (auto *Param : FD->params()) { + for (auto *Param : FD->parameters()) { Args.push_back(Param); if (!Param->hasAttr<PassObjectSizeAttr>()) continue; diff --git a/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index bdb4f67e736c636b80ba9d5c883d4fd79932f664..2aa06062a571dff5d15a5505d8ca6609f98fe246 100644 --- a/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -105,7 +105,7 @@ class PCHContainerGenerator : public ASTConsumer { return true; SmallVector<QualType, 16> ArgTypes; - for (auto i : D->params()) + for (auto i : D->parameters()) ArgTypes.push_back(i->getType()); QualType RetTy = D->getReturnType(); QualType FnTy = Ctx.getFunctionType(RetTy, ArgTypes, @@ -124,7 +124,7 @@ class PCHContainerGenerator : public ASTConsumer { ArgTypes.push_back(D->getSelfType(Ctx, D->getClassInterface(), selfIsPseudoStrong, selfIsConsumed)); ArgTypes.push_back(Ctx.getObjCSelType()); - for (auto i : D->params()) + for (auto i : D->parameters()) ArgTypes.push_back(i->getType()); QualType RetTy = D->getReturnType(); QualType FnTy = Ctx.getFunctionType(RetTy, ArgTypes, diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp index 52776b6a848377dfb4da042ddae025e874699d23..d5fc289d3d2e939d7f0e5de94268733c85ae856c 100644 --- a/lib/Frontend/ASTConsumers.cpp +++ b/lib/Frontend/ASTConsumers.cpp @@ -268,7 +268,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, // Print the parameters. Out << "("; bool PrintComma = false; - for (auto I : FD->params()) { + for (auto I : FD->parameters()) { if (PrintComma) Out << ", "; else diff --git a/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/lib/Frontend/Rewrite/RewriteModernObjC.cpp index b7b70789467e2c5de880ad87da5880757e0d129c..5538fd2835d91894412d7cd0f44ad488ede72c8f 100644 --- a/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -1286,7 +1286,7 @@ void RewriteModernObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl, ResultStr += " _cmd"; // Method arguments. - for (const auto *PDecl : OMD->params()) { + for (const auto *PDecl : OMD->parameters()) { ResultStr += ", "; if (PDecl->getType()->isObjCQualifiedIdType()) { ResultStr += "id "; @@ -2785,7 +2785,7 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) { SmallVector<QualType, 4> ArgTypes; ArgTypes.push_back(Context->getObjCClassType()); ArgTypes.push_back(Context->getObjCSelType()); - for (const auto *PI : ArrayMethod->params()) + for (const auto *PI : ArrayMethod->parameters()) ArgTypes.push_back(PI->getType()); QualType returnType = Exp->getType(); @@ -2932,7 +2932,7 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral SmallVector<QualType, 8> ArgTypes; ArgTypes.push_back(Context->getObjCClassType()); ArgTypes.push_back(Context->getObjCSelType()); - for (const auto *PI : DictMethod->params()) { + for (const auto *PI : DictMethod->parameters()) { QualType T = PI->getType(); if (const PointerType* PT = T->getAs<PointerType>()) { QualType PointeeTy = PT->getPointeeType(); @@ -3497,7 +3497,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, ArgTypes.push_back(Context->getObjCSelType()); if (ObjCMethodDecl *OMD = Exp->getMethodDecl()) { // Push any user argument types. - for (const auto *PI : OMD->params()) { + for (const auto *PI : OMD->parameters()) { QualType t = PI->getType()->isObjCQualifiedIdType() ? Context->getObjCIdType() : PI->getType(); diff --git a/lib/Frontend/Rewrite/RewriteObjC.cpp b/lib/Frontend/Rewrite/RewriteObjC.cpp index 48c31b031458c87a8b2c99b79f2327892a6d8d8b..fc938720d4e6e31eee0260c2b8d878fc95848dc2 100644 --- a/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -1118,7 +1118,7 @@ void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl, ResultStr += " _cmd"; // Method arguments. - for (const auto *PDecl : OMD->params()) { + for (const auto *PDecl : OMD->parameters()) { ResultStr += ", "; if (PDecl->getType()->isObjCQualifiedIdType()) { ResultStr += "id "; @@ -2917,7 +2917,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, ArgTypes.push_back(Context->getObjCSelType()); if (ObjCMethodDecl *OMD = Exp->getMethodDecl()) { // Push any user argument types. - for (const auto *PI : OMD->params()) { + for (const auto *PI : OMD->parameters()) { QualType t = PI->getType()->isObjCQualifiedIdType() ? Context->getObjCIdType() : PI->getType(); diff --git a/lib/Index/IndexDecl.cpp b/lib/Index/IndexDecl.cpp index 5f5c49a2e3345b17099ef3e412302f8738634071..eb3e151147356a7678513c7633b16a3bc764dedb 100644 --- a/lib/Index/IndexDecl.cpp +++ b/lib/Index/IndexDecl.cpp @@ -67,7 +67,7 @@ public: } } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { if (FD->isThisDeclarationADefinition()) { - for (auto PI : FD->params()) { + for (auto PI : FD->parameters()) { IndexCtx.handleDecl(PI); } } @@ -79,7 +79,7 @@ public: if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic)) return false; IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D); - for (const auto *I : D->params()) + for (const auto *I : D->parameters()) handleDeclarator(I, D); if (D->isThisDeclarationADefinition()) { diff --git a/lib/Index/USRGeneration.cpp b/lib/Index/USRGeneration.cpp index 40283dcd68635664fa6c29b956087e6881f055d0..11ee873189819e6eef56acf3eddd9cf8167e4ad4 100644 --- a/lib/Index/USRGeneration.cpp +++ b/lib/Index/USRGeneration.cpp @@ -233,7 +233,7 @@ void USRGenerator::VisitFunctionDecl(const FunctionDecl *D) { } // Mangle in type information for the arguments. - for (auto PD : D->params()) { + for (auto PD : D->parameters()) { Out << '#'; VisitType(PD->getType()); } diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 5761ece2fa8ea60fb2135c7c85ee81b461c78528..49548608a6482842632b5d7854e89abb5101499b 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -9186,13 +9186,10 @@ static void diagnoseArrayStarInParamType(Sema &S, QualType PType, /// takes care of any checks that cannot be performed on the /// declaration itself, e.g., that the types of each of the function /// parameters are complete. -bool Sema::CheckParmsForFunctionDef(ParmVarDecl *const *P, - ParmVarDecl *const *PEnd, +bool Sema::CheckParmsForFunctionDef(ArrayRef<ParmVarDecl *> Parameters, bool CheckParameterNames) { bool HasInvalidParm = false; - for (; P != PEnd; ++P) { - ParmVarDecl *Param = *P; - + for (ParmVarDecl *Param : Parameters) { // C99 6.7.5.3p4: the parameters in a parameter type list in a // function declarator that is part of a function definition of // that function shall not have incomplete type. diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 2b226b8e7559e0e7b66d9b280423637543aacb60..d910c6f8ad1b2fd052d3c7fe039821b26248b4ec 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -3208,7 +3208,7 @@ static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext, // We need to have names for all of the parameters, if we're going to // generate a forwarding call. - for (auto P : Method->params()) + for (auto P : Method->parameters()) if (!P->getDeclName()) return; @@ -3240,7 +3240,7 @@ static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext, Overridden->getNameAsString())); Builder.AddChunk(CodeCompletionString::CK_LeftParen); bool FirstParam = true; - for (auto P : Method->params()) { + for (auto P : Method->parameters()) { if (FirstParam) FirstParam = false; else diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 0e9e9e55ff096d4aceba745690a210e7ed63d27c..c46e39dc9aace5ba5fc3494bdd82d68353744234 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4134,7 +4134,7 @@ InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner, IndirectFieldDecl *IndirectField = IndirectFieldDecl::Create( SemaRef.Context, Owner, VD->getLocation(), VD->getIdentifier(), - VD->getType(), NamedChain, Chaining.size()); + VD->getType(), {NamedChain, Chaining.size()}); for (const auto *Attr : VD->attrs()) IndirectField->addAttr(Attr->clone(SemaRef.Context)); @@ -8529,12 +8529,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, } llvm::SmallPtrSet<const Type *, 16> ValidTypes; - for (auto Param : NewFD->params()) + for (auto Param : NewFD->parameters()) checkIsValidOpenCLKernelParameter(*this, D, Param, ValidTypes); } - for (FunctionDecl::param_iterator PI = NewFD->param_begin(), - PE = NewFD->param_end(); PI != PE; ++PI) { - ParmVarDecl *Param = *PI; + for (const ParmVarDecl *Param : NewFD->parameters()) { QualType PT = Param->getType(); // OpenCL 2.0 pipe restrictions forbids pipe packet types to be non-value @@ -10866,26 +10864,23 @@ ParmVarDecl *Sema::BuildParmVarDeclForTypedef(DeclContext *DC, return Param; } -void Sema::DiagnoseUnusedParameters(ParmVarDecl * const *Param, - ParmVarDecl * const *ParamEnd) { +void Sema::DiagnoseUnusedParameters(ArrayRef<ParmVarDecl *> Parameters) { // Don't diagnose unused-parameter errors in template instantiations; we // will already have done so in the template itself. if (!ActiveTemplateInstantiations.empty()) return; - for (; Param != ParamEnd; ++Param) { - if (!(*Param)->isReferenced() && (*Param)->getDeclName() && - !(*Param)->hasAttr<UnusedAttr>()) { - Diag((*Param)->getLocation(), diag::warn_unused_parameter) - << (*Param)->getDeclName(); + for (const ParmVarDecl *Parameter : Parameters) { + if (!Parameter->isReferenced() && Parameter->getDeclName() && + !Parameter->hasAttr<UnusedAttr>()) { + Diag(Parameter->getLocation(), diag::warn_unused_parameter) + << Parameter->getDeclName(); } } } -void Sema::DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl * const *Param, - ParmVarDecl * const *ParamEnd, - QualType ReturnTy, - NamedDecl *D) { +void Sema::DiagnoseSizeOfParametersAndReturnValue( + ArrayRef<ParmVarDecl *> Parameters, QualType ReturnTy, NamedDecl *D) { if (LangOpts.NumLargeByValueCopy == 0) // No check. return; @@ -10900,14 +10895,14 @@ void Sema::DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl * const *Param, // Warn if any parameter is pass-by-value and larger than the specified // threshold. - for (; Param != ParamEnd; ++Param) { - QualType T = (*Param)->getType(); + for (const ParmVarDecl *Parameter : Parameters) { + QualType T = Parameter->getType(); if (T->isDependentType() || !T.isPODType(Context)) continue; unsigned Size = Context.getTypeSizeInChars(T).getQuantity(); if (Size > LangOpts.NumLargeByValueCopy) - Diag((*Param)->getLocation(), diag::warn_parameter_size) - << (*Param)->getDeclName() << Size; + Diag(Parameter->getLocation(), diag::warn_parameter_size) + << Parameter->getDeclName() << Size; } } @@ -11249,11 +11244,11 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D, PushDeclContext(FnBodyScope, FD); // Check the validity of our function parameters - CheckParmsForFunctionDef(FD->param_begin(), FD->param_end(), + CheckParmsForFunctionDef(FD->parameters(), /*CheckParameterNames=*/true); // Introduce our parameters into the function scope - for (auto Param : FD->params()) { + for (auto Param : FD->parameters()) { Param->setOwningFunction(FD); // If this has an identifier, add it to the scope stack. @@ -11467,8 +11462,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, if (!FD->isInvalidDecl()) { // Don't diagnose unused parameters of defaulted or deleted functions. if (!FD->isDeleted() && !FD->isDefaulted()) - DiagnoseUnusedParameters(FD->param_begin(), FD->param_end()); - DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), FD->param_end(), + DiagnoseUnusedParameters(FD->parameters()); + DiagnoseSizeOfParametersAndReturnValue(FD->parameters(), FD->getReturnType(), FD); // If this is a structor, we need a vtable. @@ -11539,8 +11534,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, assert(MD == getCurMethodDecl() && "Method parsing confused"); MD->setBody(Body); if (!MD->isInvalidDecl()) { - DiagnoseUnusedParameters(MD->param_begin(), MD->param_end()); - DiagnoseSizeOfParametersAndReturnValue(MD->param_begin(), MD->param_end(), + DiagnoseUnusedParameters(MD->parameters()); + DiagnoseSizeOfParametersAndReturnValue(MD->parameters(), MD->getReturnType(), MD); if (Body) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 8eeaef7df58eb6b5d18e5df840d479daa0044da8..8c0e9eaddffca6ff0db7f43552c25335f107f805 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -11823,7 +11823,7 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) { diag::err_operator_overload_static) << FnDecl->getDeclName(); } else { bool ClassOrEnumParam = false; - for (auto Param : FnDecl->params()) { + for (auto Param : FnDecl->parameters()) { QualType ParamType = Param->getType().getNonReferenceType(); if (ParamType->isDependentType() || ParamType->isRecordType() || ParamType->isEnumeralType()) { @@ -11845,7 +11845,7 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) { // Only the function-call operator allows default arguments // (C++ [over.call]p1). if (Op != OO_Call) { - for (auto Param : FnDecl->params()) { + for (auto Param : FnDecl->parameters()) { if (Param->hasDefaultArg()) return Diag(Param->getLocation(), diag::err_operator_overload_default_arg) @@ -12110,7 +12110,7 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) { // A parameter-declaration-clause containing a default argument is not // equivalent to any of the permitted forms. - for (auto Param : FnDecl->params()) { + for (auto Param : FnDecl->parameters()) { if (Param->hasDefaultArg()) { Diag(Param->getDefaultArgRange().getBegin(), diag::err_literal_operator_default_argument) diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 41166960fa63577aca3d60442bc3d0704b18355c..f4d82b3c31518d0b788f83e1766e21c874bf865a 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -319,11 +319,11 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { PushOnScopeChains(MDecl->getCmdDecl(), FnBodyScope); // The ObjC parser requires parameter names so there's no need to check. - CheckParmsForFunctionDef(MDecl->param_begin(), MDecl->param_end(), + CheckParmsForFunctionDef(MDecl->parameters(), /*CheckParameterNames=*/false); // Introduce all of the other parameters into this scope. - for (auto *Param : MDecl->params()) { + for (auto *Param : MDecl->parameters()) { if (!Param->isInvalidDecl() && getLangOpts().ObjCAutoRefCount && !HasExplicitOwnershipAttr(*this, Param)) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ab1180ed99f86bbbcbd724a2953525683d94ce44..05aa18c633810c8b7da640a997909b754b119336 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -12028,8 +12028,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, // Set the parameters on the block decl. if (!Params.empty()) { CurBlock->TheDecl->setParams(Params); - CheckParmsForFunctionDef(CurBlock->TheDecl->param_begin(), - CurBlock->TheDecl->param_end(), + CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(), /*CheckParameterNames=*/false); } @@ -12037,7 +12036,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo); // Put the parameter variables in scope. - for (auto AI : CurBlock->TheDecl->params()) { + for (auto AI : CurBlock->TheDecl->parameters()) { AI->setOwningFunction(CurBlock->TheDecl); // If this has an identifier, add it to the scope stack. @@ -12137,8 +12136,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, BlockTy = Context.getFunctionType(RetTy, None, EPI); } - DiagnoseUnusedParameters(BSI->TheDecl->param_begin(), - BSI->TheDecl->param_end()); + DiagnoseUnusedParameters(BSI->TheDecl->parameters()); BlockTy = Context.getBlockPointerType(BlockTy); // If needed, diagnose invalid gotos and switches in the block. diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index 1f5f63a4144a7a64cf8047044597c9b3636573e0..73e0077d193927cea4a978eaa753d4b45acf0a71 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -415,11 +415,10 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, // Add parameters. if (!Params.empty()) { Method->setParams(Params); - CheckParmsForFunctionDef(const_cast<ParmVarDecl **>(Params.begin()), - const_cast<ParmVarDecl **>(Params.end()), + CheckParmsForFunctionDef(Params, /*CheckParameterNames=*/false); - - for (auto P : Method->params()) + + for (auto P : Method->parameters()) P->setOwningFunction(Method); } diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index e5c24252eda25b1ea033287e2a43131dd76f8594..3bfa34c63f5d3c4f09bf46c5f725132fefe68168 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -2480,7 +2480,7 @@ Sema::SubstituteExplicitTemplateArguments( if (ExplicitTemplateArgs.size() == 0) { // No arguments to substitute; just copy over the parameter types and // fill in the function type. - for (auto P : Function->params()) + for (auto P : Function->parameters()) ParamTypes.push_back(P->getType()); if (FunctionType) @@ -2563,8 +2563,7 @@ Sema::SubstituteExplicitTemplateArguments( // return type, substitute it after the arguments to ensure we substitute // in lexical order. if (Proto->hasTrailingReturn()) { - if (SubstParmTypes(Function->getLocation(), - Function->param_begin(), Function->getNumParams(), + if (SubstParmTypes(Function->getLocation(), Function->parameters(), Proto->getExtParameterInfosOrNull(), MultiLevelTemplateArgumentList(*ExplicitArgumentList), ParamTypes, /*params*/ nullptr, ExtParamInfos)) @@ -2601,8 +2600,7 @@ Sema::SubstituteExplicitTemplateArguments( // Instantiate the types of each of the function parameters given the // explicitly-specified template arguments if we didn't do so earlier. if (!Proto->hasTrailingReturn() && - SubstParmTypes(Function->getLocation(), - Function->param_begin(), Function->getNumParams(), + SubstParmTypes(Function->getLocation(), Function->parameters(), Proto->getExtParameterInfosOrNull(), MultiLevelTemplateArgumentList(*ExplicitArgumentList), ParamTypes, /*params*/ nullptr, ExtParamInfos)) diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 24a47d19421dfcd896c03e94c800c55241889e9c..10a3b865bc8a290b7cfb274cc0d9aa10bff416de 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -1714,23 +1714,21 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, /// \brief Substitute the given template arguments into the given set of /// parameters, producing the set of parameter types that would be generated /// from such a substitution. -bool Sema::SubstParmTypes(SourceLocation Loc, - ParmVarDecl **Params, unsigned NumParams, - const FunctionProtoType::ExtParameterInfo *ExtParamInfos, - const MultiLevelTemplateArgumentList &TemplateArgs, - SmallVectorImpl<QualType> &ParamTypes, - SmallVectorImpl<ParmVarDecl *> *OutParams, - ExtParameterInfoBuilder &ParamInfos) { +bool Sema::SubstParmTypes( + SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, + const FunctionProtoType::ExtParameterInfo *ExtParamInfos, + const MultiLevelTemplateArgumentList &TemplateArgs, + SmallVectorImpl<QualType> &ParamTypes, + SmallVectorImpl<ParmVarDecl *> *OutParams, + ExtParameterInfoBuilder &ParamInfos) { assert(!ActiveTemplateInstantiations.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"); TemplateInstantiator Instantiator(*this, TemplateArgs, Loc, DeclarationName()); - return Instantiator.TransformFunctionTypeParams(Loc, Params, NumParams, - nullptr, ExtParamInfos, - ParamTypes, OutParams, - ParamInfos); + return Instantiator.TransformFunctionTypeParams( + Loc, Params, nullptr, ExtParamInfos, ParamTypes, OutParams, ParamInfos); } /// \brief Perform substitution on the base class specifiers of the diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 78de86e49d4fe7a8a3e716b5063e9dd69461c709..58c0ab027eb900f578b23865513b6d0d01dce22e 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -803,7 +803,7 @@ Decl *TemplateDeclInstantiator::VisitIndirectFieldDecl(IndirectFieldDecl *D) { QualType T = cast<FieldDecl>(NamedChain[i-1])->getType(); IndirectFieldDecl *IndirectField = IndirectFieldDecl::Create( SemaRef.Context, Owner, D->getLocation(), D->getIdentifier(), T, - NamedChain, D->getChainingSize()); + {NamedChain, D->getChainingSize()}); for (const auto *Attr : D->attrs()) IndirectField->addAttr(Attr->clone(SemaRef.Context)); @@ -3301,9 +3301,9 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, // synthesized in the method declaration. SmallVector<QualType, 4> ParamTypes; Sema::ExtParameterInfoBuilder ExtParamInfos; - if (SemaRef.SubstParmTypes(D->getLocation(), D->param_begin(), - D->getNumParams(), nullptr, TemplateArgs, - ParamTypes, &Params, ExtParamInfos)) + if (SemaRef.SubstParmTypes(D->getLocation(), D->parameters(), nullptr, + TemplateArgs, ParamTypes, &Params, + ExtParamInfos)) return nullptr; } diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index a7b994d9869d23911ee16c649132f12ce110a650..c90e0fa2ca031e4644305028fd3d8cd9b6ebb68c 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -612,13 +612,12 @@ public: /// variables vector are acceptable. /// /// Return true on error. - bool TransformFunctionTypeParams(SourceLocation Loc, - ParmVarDecl **Params, unsigned NumParams, - const QualType *ParamTypes, - const FunctionProtoType::ExtParameterInfo *ParamInfos, - SmallVectorImpl<QualType> &PTypes, - SmallVectorImpl<ParmVarDecl*> *PVars, - Sema::ExtParameterInfoBuilder &PInfos); + bool TransformFunctionTypeParams( + SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, + const QualType *ParamTypes, + const FunctionProtoType::ExtParameterInfo *ParamInfos, + SmallVectorImpl<QualType> &PTypes, SmallVectorImpl<ParmVarDecl *> *PVars, + Sema::ExtParameterInfoBuilder &PInfos); /// \brief Transforms a single function-type parameter. Return null /// on error. @@ -4663,17 +4662,17 @@ ParmVarDecl *TreeTransform<Derived>::TransformFunctionTypeParam( return newParm; } -template<typename Derived> -bool TreeTransform<Derived>:: - TransformFunctionTypeParams(SourceLocation Loc, - ParmVarDecl **Params, unsigned NumParams, - const QualType *ParamTypes, - const FunctionProtoType::ExtParameterInfo *ParamInfos, - SmallVectorImpl<QualType> &OutParamTypes, - SmallVectorImpl<ParmVarDecl*> *PVars, - Sema::ExtParameterInfoBuilder &PInfos) { +template <typename Derived> +bool TreeTransform<Derived>::TransformFunctionTypeParams( + SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, + const QualType *ParamTypes, + const FunctionProtoType::ExtParameterInfo *ParamInfos, + SmallVectorImpl<QualType> &OutParamTypes, + SmallVectorImpl<ParmVarDecl *> *PVars, + Sema::ExtParameterInfoBuilder &PInfos) { int indexAdjustment = 0; + unsigned NumParams = Params.size(); for (unsigned i = 0; i != NumParams; ++i) { if (ParmVarDecl *OldParm = Params[i]) { assert(OldParm->getFunctionScopeIndex() == i); @@ -4908,7 +4907,7 @@ QualType TreeTransform<Derived>::TransformFunctionProtoType( if (T->hasTrailingReturn()) { if (getDerived().TransformFunctionTypeParams( - TL.getBeginLoc(), TL.getParmArray(), TL.getNumParams(), + TL.getBeginLoc(), TL.getParams(), TL.getTypePtr()->param_type_begin(), T->getExtParameterInfosOrNull(), ParamTypes, &ParamDecls, ExtParamInfos)) @@ -4934,7 +4933,7 @@ QualType TreeTransform<Derived>::TransformFunctionProtoType( return QualType(); if (getDerived().TransformFunctionTypeParams( - TL.getBeginLoc(), TL.getParmArray(), TL.getNumParams(), + TL.getBeginLoc(), TL.getParams(), TL.getTypePtr()->param_type_begin(), T->getExtParameterInfosOrNull(), ParamTypes, &ParamDecls, ExtParamInfos)) @@ -11196,13 +11195,10 @@ TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) { // Parameter substitution. Sema::ExtParameterInfoBuilder extParamInfos; - if (getDerived().TransformFunctionTypeParams(E->getCaretLocation(), - oldBlock->param_begin(), - oldBlock->param_size(), - nullptr, - exprFunctionType->getExtParameterInfosOrNull(), - paramTypes, ¶ms, - extParamInfos)) { + if (getDerived().TransformFunctionTypeParams( + E->getCaretLocation(), oldBlock->parameters(), nullptr, + exprFunctionType->getExtParameterInfosOrNull(), paramTypes, ¶ms, + extParamInfos)) { getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr); return ExprError(); } diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 1e26f0f9c0db373ca53f955a02b48b3126dbbb65..6a22f669816ece5bbb64e92d61a609f74db709e0 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -597,7 +597,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { } Record.push_back(D->param_size()); - for (auto P : D->params()) + for (auto P : D->parameters()) Record.AddDeclRef(P); Code = serialization::DECL_FUNCTION; } @@ -637,7 +637,7 @@ void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) { Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo()); Record.AddSourceLocation(D->getLocEnd()); Record.push_back(D->param_size()); - for (const auto *P : D->params()) + for (const auto *P : D->parameters()) Record.AddDeclRef(P); Record.push_back(D->SelLocsKind); diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index cf4c011d5a1a04b21c9c5072443104eea01ab373..e06662b1693426c460c5ca6594b2e03379190a1e 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -944,7 +944,7 @@ static bool treatUnusedNewEscaped(const CXXNewExpr *NE) { const CXXConstructorDecl *CtorD = ConstructE->getConstructor(); // Iterate over the constructor parameters. - for (const auto *CtorParam : CtorD->params()) { + for (const auto *CtorParam : CtorD->parameters()) { QualType CtorParamPointeeT = CtorParam->getType()->getPointeeType(); if (CtorParamPointeeT.isNull()) diff --git a/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp b/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp index dab068b27e80c386be3670f4f68293be9bc84baf..559c75d7a5b06f71bb1ac1d07d8e80bae306870c 100644 --- a/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp @@ -61,7 +61,7 @@ void NSErrorMethodChecker::checkASTDecl(const ObjCMethodDecl *D, II = &D->getASTContext().Idents.get("NSError"); bool hasNSError = false; - for (const auto *I : D->params()) { + for (const auto *I : D->parameters()) { if (IsNSError(I->getType(), II)) { hasNSError = true; break; @@ -108,7 +108,7 @@ void CFErrorFunctionChecker::checkASTDecl(const FunctionDecl *D, II = &D->getASTContext().Idents.get("CFErrorRef"); bool hasCFError = false; - for (auto I : D->params()) { + for (auto I : D->parameters()) { if (IsCFError(I->getType(), II)) { hasCFError = true; break; diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index dc95b599a70ea8aba3d6ed8b3374dd74a2e96745..a0bb7d52cb543f562c517777c4adf9e736df395d 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -935,7 +935,7 @@ bool CursorVisitor::VisitObjCMethodDecl(ObjCMethodDecl *ND) { if (Visit(TSInfo->getTypeLoc())) return true; - for (const auto *P : ND->params()) { + for (const auto *P : ND->parameters()) { if (Visit(MakeCXCursor(P, TU, RegionOfInterest))) return true; } @@ -6278,7 +6278,7 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { if (Method->getObjCDeclQualifier()) HasContextSensitiveKeywords = true; else { - for (const auto *P : Method->params()) { + for (const auto *P : Method->parameters()) { if (P->getObjCDeclQualifier()) { HasContextSensitiveKeywords = true; break;