From 896b32f9352103f8a4a7ff9acc608b77f6ddb2ba Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Mon, 10 Jun 2013 20:51:09 +0000 Subject: [PATCH] Use FPT::getArgTypes() instead of manually building ArrayRefs Made significantly easier with git-clang-format. Differential Revision: http://llvm-reviews.chandlerc.com/D947 llvm-svn: 183694 --- clang/lib/AST/ASTContext.cpp | 17 ++++----------- clang/lib/AST/ASTImporter.cpp | 5 +---- clang/lib/AST/LambdaMangleContext.cpp | 9 +++----- clang/lib/Sema/SemaDecl.cpp | 13 +++--------- clang/lib/Sema/SemaExceptionSpec.cpp | 14 ++++--------- clang/lib/Sema/SemaExpr.cpp | 13 +++--------- clang/lib/Sema/SemaLambda.cpp | 21 ++++++------------- clang/lib/Sema/SemaTemplate.cpp | 4 +--- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 18 +++++----------- clang/lib/Sema/SemaType.cpp | 4 +--- 10 files changed, 31 insertions(+), 87 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 44ff94e35843..406760400c4d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2074,10 +2074,7 @@ const FunctionType *ASTContext::adjustFunctionType(const FunctionType *T, const FunctionProtoType *FPT = cast(T); FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExtInfo = Info; - Result = getFunctionType(FPT->getResultType(), - ArrayRef(FPT->arg_type_begin(), - FPT->getNumArgs()), - EPI); + Result = getFunctionType(FPT->getResultType(), FPT->getArgTypes(), EPI); } return cast(Result.getTypePtr()); @@ -7039,10 +7036,7 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, FunctionProtoType::ExtProtoInfo EPI = proto->getExtProtoInfo(); EPI.ExtInfo = einfo; - return getFunctionType(retType, - ArrayRef(proto->arg_type_begin(), - proto->getNumArgs()), - EPI); + return getFunctionType(retType, proto->getArgTypes(), EPI); } if (allLTypes) return lhs; @@ -7390,11 +7384,8 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) { if (const FunctionProtoType *FPT = cast(F)) { FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExtInfo = getFunctionExtInfo(LHS); - QualType ResultType - = getFunctionType(OldReturnType, - ArrayRef(FPT->arg_type_begin(), - FPT->getNumArgs()), - EPI); + QualType ResultType = + getFunctionType(OldReturnType, FPT->getArgTypes(), EPI); return ResultType; } } diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 204b9d001c28..41a67af64d6e 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -2664,10 +2664,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { FromEPI.NoexceptExpr) { FunctionProtoType::ExtProtoInfo DefaultEPI; FromTy = Importer.getFromContext().getFunctionType( - FromFPT->getResultType(), - ArrayRef(FromFPT->arg_type_begin(), - FromFPT->getNumArgs()), - DefaultEPI); + FromFPT->getResultType(), FromFPT->getArgTypes(), DefaultEPI); usedDifferentExceptionSpec = true; } } diff --git a/clang/lib/AST/LambdaMangleContext.cpp b/clang/lib/AST/LambdaMangleContext.cpp index 54f445df4b64..10b01a6999be 100644 --- a/clang/lib/AST/LambdaMangleContext.cpp +++ b/clang/lib/AST/LambdaMangleContext.cpp @@ -22,12 +22,9 @@ unsigned LambdaMangleContext::getManglingNumber(CXXMethodDecl *CallOperator) { const FunctionProtoType *Proto = CallOperator->getType()->getAs(); ASTContext &Context = CallOperator->getASTContext(); - - QualType Key = - Context.getFunctionType(Context.VoidTy, - ArrayRef(Proto->arg_type_begin(), - Proto->getNumArgs()), - FunctionProtoType::ExtProtoInfo()); + + QualType Key = Context.getFunctionType(Context.VoidTy, Proto->getArgTypes(), + FunctionProtoType::ExtProtoInfo()); Key = Context.getCanonicalType(Key); return ++ManglingNumbers[Key->castAs()]; } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index e6a89461b459..c17328d9cff2 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5907,10 +5907,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, T = Context.getObjCObjectPointerType(T); if (const FunctionProtoType *FPT = dyn_cast(R)) { FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); - R = Context.getFunctionType(T, - ArrayRef(FPT->arg_type_begin(), - FPT->getNumArgs()), - EPI); + R = Context.getFunctionType(T, FPT->getArgTypes(), EPI); } else if (isa(R)) R = Context.getFunctionNoProtoType(T); @@ -6209,9 +6206,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExceptionSpecType = EST_BasicNoexcept; NewFD->setType(Context.getFunctionType(FPT->getResultType(), - ArrayRef(FPT->arg_type_begin(), - FPT->getNumArgs()), - EPI)); + FPT->getArgTypes(), EPI)); } } @@ -6804,9 +6799,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.TypeQuals |= Qualifiers::Const; MD->setType(Context.getFunctionType(FPT->getResultType(), - ArrayRef(FPT->arg_type_begin(), - FPT->getNumArgs()), - EPI)); + FPT->getArgTypes(), EPI)); // Warn that we did this, if we're not performing template instantiation. // In that case, we'll have warned already when the template was defined. diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index 1a5f4824d091..a121a75fa485 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -203,11 +203,8 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { Old->isExternC()) { FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo(); EPI.ExceptionSpecType = EST_DynamicNone; - QualType NewType = - Context.getFunctionType(NewProto->getResultType(), - ArrayRef(NewProto->arg_type_begin(), - NewProto->getNumArgs()), - EPI); + QualType NewType = Context.getFunctionType(NewProto->getResultType(), + NewProto->getArgTypes(), EPI); New->setType(NewType); return false; } @@ -228,11 +225,8 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { // Update the type of the function with the appropriate exception // specification. - QualType NewType = - Context.getFunctionType(NewProto->getResultType(), - ArrayRef(NewProto->arg_type_begin(), - NewProto->getNumArgs()), - EPI); + QualType NewType = Context.getFunctionType(NewProto->getResultType(), + NewProto->getArgTypes(), EPI); New->setType(NewType); // If exceptions are disabled, suppress the warning about missing diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f3fc11395448..fcfe17a007bc 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -10027,11 +10027,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.TypeQuals = 0; // FIXME: silently? EPI.ExtInfo = Ext; - BlockTy = - Context.getFunctionType(RetTy, - ArrayRef(FPT->arg_type_begin(), - FPT->getNumArgs()), - EPI); + BlockTy = Context.getFunctionType(RetTy, FPT->getArgTypes(), EPI); } // If we don't have a function type, just build one from nothing. @@ -12200,11 +12196,8 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) { // Rebuild the function type, replacing the result type with DestType. if (const FunctionProtoType *Proto = dyn_cast(FnType)) - DestType = - S.Context.getFunctionType(DestType, - ArrayRef(Proto->arg_type_begin(), - Proto->getNumArgs()), - Proto->getExtProtoInfo()); + DestType = S.Context.getFunctionType(DestType, Proto->getArgTypes(), + Proto->getExtProtoInfo()); else DestType = S.Context.getFunctionNoProtoType(DestType, FnType->getExtInfo()); diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 3402f220625f..f28ea0a09536 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -811,11 +811,8 @@ static void addFunctionPointerConversion(Sema &S, { FunctionProtoType::ExtProtoInfo ExtInfo = Proto->getExtProtoInfo(); ExtInfo.TypeQuals = 0; - FunctionTy = - S.Context.getFunctionType(Proto->getResultType(), - ArrayRef(Proto->arg_type_begin(), - Proto->getNumArgs()), - ExtInfo); + FunctionTy = S.Context.getFunctionType(Proto->getResultType(), + Proto->getArgTypes(), ExtInfo); FunctionPtrTy = S.Context.getPointerType(FunctionTy); } @@ -883,11 +880,8 @@ static void addBlockPointerConversion(Sema &S, { FunctionProtoType::ExtProtoInfo ExtInfo = Proto->getExtProtoInfo(); ExtInfo.TypeQuals = 0; - QualType FunctionTy - = S.Context.getFunctionType(Proto->getResultType(), - ArrayRef(Proto->arg_type_begin(), - Proto->getNumArgs()), - ExtInfo); + QualType FunctionTy = S.Context.getFunctionType( + Proto->getResultType(), Proto->getArgTypes(), ExtInfo); BlockPtrTy = S.Context.getBlockPointerType(FunctionTy); } @@ -1010,11 +1004,8 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, // Create a function type with the inferred return type. const FunctionProtoType *Proto = CallOperator->getType()->getAs(); - QualType FunctionTy - = Context.getFunctionType(LSI->ReturnType, - ArrayRef(Proto->arg_type_begin(), - Proto->getNumArgs()), - Proto->getExtProtoInfo()); + QualType FunctionTy = Context.getFunctionType( + LSI->ReturnType, Proto->getArgTypes(), Proto->getExtProtoInfo()); CallOperator->setType(FunctionTy); } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 9531b2e91df5..7ad313162701 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -5950,9 +5950,7 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD, const FunctionProtoType *FPT = FT->castAs(); FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.TypeQuals |= Qualifiers::Const; - FT = Context.getFunctionType(FPT->getResultType(), - ArrayRef(FPT->arg_type_begin(), - FPT->getNumArgs()), + FT = Context.getFunctionType(FPT->getResultType(), FPT->getArgTypes(), EPI); } } diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 9d1757d878d1..030b9c72c1ce 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1143,9 +1143,7 @@ static QualType adjustFunctionTypeForInstantiation(ASTContext &Context, FunctionProtoType::ExtProtoInfo NewEPI = NewFunc->getExtProtoInfo(); NewEPI.ExtInfo = OrigFunc->getExtInfo(); return Context.getFunctionType(NewFunc->getResultType(), - ArrayRef(NewFunc->arg_type_begin(), - NewFunc->getNumArgs()), - NewEPI); + NewFunc->getArgTypes(), NewEPI); } /// Normal class members are of more specific types and therefore @@ -2680,9 +2678,7 @@ static void InstantiateExceptionSpec(Sema &SemaRef, FunctionDecl *New, EPI.NoexceptExpr = NoexceptExpr; New->setType(SemaRef.Context.getFunctionType(NewProto->getResultType(), - ArrayRef(NewProto->arg_type_begin(), - NewProto->getNumArgs()), - EPI)); + NewProto->getArgTypes(), EPI)); } void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, @@ -2699,9 +2695,7 @@ void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo(); EPI.ExceptionSpecType = EST_None; Decl->setType(Context.getFunctionType(Proto->getResultType(), - ArrayRef(Proto->arg_type_begin(), - Proto->getNumArgs()), - EPI)); + Proto->getArgTypes(), EPI)); return; } @@ -2780,10 +2774,8 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, EPI.ExceptionSpecType = NewEST; EPI.ExceptionSpecDecl = New; EPI.ExceptionSpecTemplate = ExceptionSpecTemplate; - New->setType(SemaRef.Context.getFunctionType(NewProto->getResultType(), - ArrayRef(NewProto->arg_type_begin(), - NewProto->getNumArgs()), - EPI)); + New->setType(SemaRef.Context.getFunctionType( + NewProto->getResultType(), NewProto->getArgTypes(), EPI)); } else { ::InstantiateExceptionSpec(SemaRef, New, Proto, TemplateArgs); } diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index e27d627d3ff1..99beabeda9ba 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -3034,9 +3034,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, EPI.TypeQuals = 0; EPI.RefQualifier = RQ_None; - T = Context.getFunctionType(FnTy->getResultType(), - ArrayRef(FnTy->arg_type_begin(), - FnTy->getNumArgs()), + T = Context.getFunctionType(FnTy->getResultType(), FnTy->getArgTypes(), EPI); // Rebuild any parens around the identifier in the function type. for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {