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
This commit is contained in:
Reid Kleckner 2013-06-10 20:51:09 +00:00
parent 6833e3fd75
commit 896b32f935
10 changed files with 31 additions and 87 deletions

View File

@ -2074,10 +2074,7 @@ const FunctionType *ASTContext::adjustFunctionType(const FunctionType *T,
const FunctionProtoType *FPT = cast<FunctionProtoType>(T);
FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
EPI.ExtInfo = Info;
Result = getFunctionType(FPT->getResultType(),
ArrayRef<QualType>(FPT->arg_type_begin(),
FPT->getNumArgs()),
EPI);
Result = getFunctionType(FPT->getResultType(), FPT->getArgTypes(), EPI);
}
return cast<FunctionType>(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<QualType>(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<FunctionProtoType>(F)) {
FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
EPI.ExtInfo = getFunctionExtInfo(LHS);
QualType ResultType
= getFunctionType(OldReturnType,
ArrayRef<QualType>(FPT->arg_type_begin(),
FPT->getNumArgs()),
EPI);
QualType ResultType =
getFunctionType(OldReturnType, FPT->getArgTypes(), EPI);
return ResultType;
}
}

View File

@ -2664,10 +2664,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
FromEPI.NoexceptExpr) {
FunctionProtoType::ExtProtoInfo DefaultEPI;
FromTy = Importer.getFromContext().getFunctionType(
FromFPT->getResultType(),
ArrayRef<QualType>(FromFPT->arg_type_begin(),
FromFPT->getNumArgs()),
DefaultEPI);
FromFPT->getResultType(), FromFPT->getArgTypes(), DefaultEPI);
usedDifferentExceptionSpec = true;
}
}

View File

@ -22,12 +22,9 @@ unsigned LambdaMangleContext::getManglingNumber(CXXMethodDecl *CallOperator) {
const FunctionProtoType *Proto
= CallOperator->getType()->getAs<FunctionProtoType>();
ASTContext &Context = CallOperator->getASTContext();
QualType Key =
Context.getFunctionType(Context.VoidTy,
ArrayRef<QualType>(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<FunctionProtoType>()];
}

View File

@ -5907,10 +5907,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
T = Context.getObjCObjectPointerType(T);
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(R)) {
FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
R = Context.getFunctionType(T,
ArrayRef<QualType>(FPT->arg_type_begin(),
FPT->getNumArgs()),
EPI);
R = Context.getFunctionType(T, FPT->getArgTypes(), EPI);
}
else if (isa<FunctionNoProtoType>(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<QualType>(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<QualType>(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.

View File

@ -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<QualType>(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<QualType>(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

View File

@ -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<QualType>(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<FunctionProtoType>(FnType))
DestType =
S.Context.getFunctionType(DestType,
ArrayRef<QualType>(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());

View File

@ -811,11 +811,8 @@ static void addFunctionPointerConversion(Sema &S,
{
FunctionProtoType::ExtProtoInfo ExtInfo = Proto->getExtProtoInfo();
ExtInfo.TypeQuals = 0;
FunctionTy =
S.Context.getFunctionType(Proto->getResultType(),
ArrayRef<QualType>(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<QualType>(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<FunctionProtoType>();
QualType FunctionTy
= Context.getFunctionType(LSI->ReturnType,
ArrayRef<QualType>(Proto->arg_type_begin(),
Proto->getNumArgs()),
Proto->getExtProtoInfo());
QualType FunctionTy = Context.getFunctionType(
LSI->ReturnType, Proto->getArgTypes(), Proto->getExtProtoInfo());
CallOperator->setType(FunctionTy);
}

View File

@ -5950,9 +5950,7 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD,
const FunctionProtoType *FPT = FT->castAs<FunctionProtoType>();
FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
EPI.TypeQuals |= Qualifiers::Const;
FT = Context.getFunctionType(FPT->getResultType(),
ArrayRef<QualType>(FPT->arg_type_begin(),
FPT->getNumArgs()),
FT = Context.getFunctionType(FPT->getResultType(), FPT->getArgTypes(),
EPI);
}
}

View File

@ -1143,9 +1143,7 @@ static QualType adjustFunctionTypeForInstantiation(ASTContext &Context,
FunctionProtoType::ExtProtoInfo NewEPI = NewFunc->getExtProtoInfo();
NewEPI.ExtInfo = OrigFunc->getExtInfo();
return Context.getFunctionType(NewFunc->getResultType(),
ArrayRef<QualType>(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<QualType>(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<QualType>(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<QualType>(NewProto->arg_type_begin(),
NewProto->getNumArgs()),
EPI));
New->setType(SemaRef.Context.getFunctionType(
NewProto->getResultType(), NewProto->getArgTypes(), EPI));
} else {
::InstantiateExceptionSpec(SemaRef, New, Proto, TemplateArgs);
}

View File

@ -3034,9 +3034,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
EPI.TypeQuals = 0;
EPI.RefQualifier = RQ_None;
T = Context.getFunctionType(FnTy->getResultType(),
ArrayRef<QualType>(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) {