diff options
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/ASTContext.cpp | 36 | ||||
-rw-r--r-- | lib/AST/ASTImporter.cpp | 7 | ||||
-rw-r--r-- | lib/AST/ExprCXX.cpp | 3 | ||||
-rw-r--r-- | lib/AST/LambdaMangleContext.cpp | 9 | ||||
-rw-r--r-- | lib/AST/Type.cpp | 20 |
5 files changed, 41 insertions, 34 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 4580424696..0b0da40550 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1974,8 +1974,10 @@ 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(), FPT->arg_type_begin(), - FPT->getNumArgs(), EPI); + Result = getFunctionType(FPT->getResultType(), + ArrayRef<QualType>(FPT->arg_type_begin(), + FPT->getNumArgs()), + EPI); } return cast<FunctionType>(Result.getTypePtr()); @@ -2640,13 +2642,15 @@ static bool isCanonicalResultType(QualType T) { /// getFunctionType - Return a normal function type with a typed argument /// list. isVariadic indicates whether the argument list includes '...'. QualType -ASTContext::getFunctionType(QualType ResultTy, - const QualType *ArgArray, unsigned NumArgs, +ASTContext::getFunctionType(QualType ResultTy, ArrayRef<QualType> ArgArray, const FunctionProtoType::ExtProtoInfo &EPI) const { + size_t NumArgs = ArgArray.size(); + // Unique functions, to guarantee there is only one function of a particular // structure. llvm::FoldingSetNodeID ID; - FunctionProtoType::Profile(ID, ResultTy, ArgArray, NumArgs, EPI, *this); + FunctionProtoType::Profile(ID, ResultTy, ArgArray.begin(), NumArgs, EPI, + *this); void *InsertPos = 0; if (FunctionProtoType *FTP = @@ -2689,9 +2693,7 @@ ASTContext::getFunctionType(QualType ResultTy, CanResultTy = getQualifiedType(CanResultTy.getUnqualifiedType(), Qs); } - Canonical = getFunctionType(CanResultTy, - CanonicalArgs.data(), NumArgs, - CanonicalEPI); + Canonical = getFunctionType(CanResultTy, CanonicalArgs, CanonicalEPI); // Get the new insert position for the node we care about. FunctionProtoType *NewIP = @@ -2724,7 +2726,7 @@ ASTContext::getFunctionType(QualType ResultTy, FunctionProtoType *FTP = (FunctionProtoType*) Allocate(Size, TypeAlignment); FunctionProtoType::ExtProtoInfo newEPI = EPI; newEPI.ExtInfo = EPI.ExtInfo.withCallingConv(CallConv); - new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, Canonical, newEPI); + new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI); Types.push_back(FTP); FunctionProtoTypes.InsertNode(FTP, InsertPos); return QualType(FTP, 0); @@ -6794,7 +6796,7 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, FunctionProtoType::ExtProtoInfo EPI = lproto->getExtProtoInfo(); EPI.ExtInfo = einfo; - return getFunctionType(retType, types.begin(), types.size(), EPI); + return getFunctionType(retType, types, EPI); } if (lproto) allRTypes = false; @@ -6831,8 +6833,10 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, FunctionProtoType::ExtProtoInfo EPI = proto->getExtProtoInfo(); EPI.ExtInfo = einfo; - return getFunctionType(retType, proto->arg_type_begin(), - proto->getNumArgs(), EPI); + return getFunctionType(retType, + ArrayRef<QualType>(proto->arg_type_begin(), + proto->getNumArgs()), + EPI); } if (allLTypes) return lhs; @@ -7165,8 +7169,10 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) { FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExtInfo = getFunctionExtInfo(LHS); QualType ResultType - = getFunctionType(OldReturnType, FPT->arg_type_begin(), - FPT->getNumArgs(), EPI); + = getFunctionType(OldReturnType, + ArrayRef<QualType>(FPT->arg_type_begin(), + FPT->getNumArgs()), + EPI); return ResultType; } } @@ -7558,7 +7564,7 @@ QualType ASTContext::GetBuiltinType(unsigned Id, EPI.ExtInfo = EI; EPI.Variadic = Variadic; - return getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(), EPI); + return getFunctionType(ResType, ArgTypes, EPI); } GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) { diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index bdf2bbc7e5..01d1a1e917 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -1619,8 +1619,7 @@ QualType ASTNodeImporter::VisitFunctionProtoType(const FunctionProtoType *T) { ToEPI.ExceptionSpecTemplate = cast_or_null<FunctionDecl>( Importer.Import(FromEPI.ExceptionSpecTemplate)); - return Importer.getToContext().getFunctionType(ToResultType, ArgTypes.data(), - ArgTypes.size(), ToEPI); + return Importer.getToContext().getFunctionType(ToResultType, ArgTypes, ToEPI); } QualType ASTNodeImporter::VisitParenType(const ParenType *T) { @@ -2660,8 +2659,8 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { FunctionProtoType::ExtProtoInfo DefaultEPI; FromTy = Importer.getFromContext().getFunctionType( FromFPT->getResultType(), - FromFPT->arg_type_begin(), - FromFPT->arg_type_end() - FromFPT->arg_type_begin(), + ArrayRef<QualType>(FromFPT->arg_type_begin(), + FromFPT->getNumArgs()), DefaultEPI); usedDifferentExceptionSpec = true; } diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index e1e96e4c5c..12a47fcd78 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -178,7 +178,8 @@ CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(ASTContext &Context, SourceLocation ColonColonLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType) : Expr(CXXPseudoDestructorExprClass, - Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, + Context.getPointerType(Context.getFunctionType(Context.VoidTy, + ArrayRef<QualType>(), FunctionProtoType::ExtProtoInfo())), VK_RValue, OK_Ordinary, /*isTypeDependent=*/(Base->isTypeDependent() || diff --git a/lib/AST/LambdaMangleContext.cpp b/lib/AST/LambdaMangleContext.cpp index 6f4fe2d4b4..54f445df4b 100644 --- a/lib/AST/LambdaMangleContext.cpp +++ b/lib/AST/LambdaMangleContext.cpp @@ -23,10 +23,11 @@ unsigned LambdaMangleContext::getManglingNumber(CXXMethodDecl *CallOperator) { = CallOperator->getType()->getAs<FunctionProtoType>(); ASTContext &Context = CallOperator->getASTContext(); - QualType Key = Context.getFunctionType(Context.VoidTy, - Proto->arg_type_begin(), - Proto->getNumArgs(), - FunctionProtoType::ExtProtoInfo()); + QualType Key = + Context.getFunctionType(Context.VoidTy, + ArrayRef<QualType>(Proto->arg_type_begin(), + Proto->getNumArgs()), + FunctionProtoType::ExtProtoInfo()); Key = Context.getCanonicalType(Key); return ++ManglingNumbers[Key->castAs<FunctionProtoType>()]; } diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index e6687a7717..f6fcab52eb 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1560,8 +1560,8 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) { llvm_unreachable("Invalid calling convention."); } -FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, - unsigned numArgs, QualType canonical, +FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> args, + QualType canonical, const ExtProtoInfo &epi) : FunctionType(FunctionProto, result, epi.TypeQuals, canonical, @@ -1570,17 +1570,17 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, result->isVariablyModifiedType(), result->containsUnexpandedParameterPack(), epi.ExtInfo), - NumArgs(numArgs), NumExceptions(epi.NumExceptions), + NumArgs(args.size()), NumExceptions(epi.NumExceptions), ExceptionSpecType(epi.ExceptionSpecType), HasAnyConsumedArgs(epi.ConsumedArguments != 0), Variadic(epi.Variadic), HasTrailingReturn(epi.HasTrailingReturn), RefQualifier(epi.RefQualifier) { - assert(NumArgs == numArgs && "function has too many parameters"); + assert(NumArgs == args.size() && "function has too many parameters"); // Fill in the trailing argument array. QualType *argSlot = reinterpret_cast<QualType*>(this+1); - for (unsigned i = 0; i != numArgs; ++i) { + for (unsigned i = 0; i != NumArgs; ++i) { if (args[i]->isDependentType()) setDependent(); else if (args[i]->isInstantiationDependentType()) @@ -1594,7 +1594,7 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, if (getExceptionSpecType() == EST_Dynamic) { // Fill in the exception array. - QualType *exnSlot = argSlot + numArgs; + QualType *exnSlot = argSlot + NumArgs; for (unsigned i = 0, e = epi.NumExceptions; i != e; ++i) { if (epi.Exceptions[i]->isDependentType()) setDependent(); @@ -1608,7 +1608,7 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, } } else if (getExceptionSpecType() == EST_ComputedNoexcept) { // Store the noexcept expression and context. - Expr **noexSlot = reinterpret_cast<Expr**>(argSlot + numArgs); + Expr **noexSlot = reinterpret_cast<Expr**>(argSlot + NumArgs); *noexSlot = epi.NoexceptExpr; if (epi.NoexceptExpr) { @@ -1621,7 +1621,7 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, } else if (getExceptionSpecType() == EST_Uninstantiated) { // Store the function decl from which we will resolve our // exception specification. - FunctionDecl **slot = reinterpret_cast<FunctionDecl**>(argSlot + numArgs); + FunctionDecl **slot = reinterpret_cast<FunctionDecl**>(argSlot + NumArgs); slot[0] = epi.ExceptionSpecDecl; slot[1] = epi.ExceptionSpecTemplate; // This exception specification doesn't make the type dependent, because @@ -1629,13 +1629,13 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, } else if (getExceptionSpecType() == EST_Unevaluated) { // Store the function decl from which we will resolve our // exception specification. - FunctionDecl **slot = reinterpret_cast<FunctionDecl**>(argSlot + numArgs); + FunctionDecl **slot = reinterpret_cast<FunctionDecl**>(argSlot + NumArgs); slot[0] = epi.ExceptionSpecDecl; } if (epi.ConsumedArguments) { bool *consumedArgs = const_cast<bool*>(getConsumedArgsBuffer()); - for (unsigned i = 0; i != numArgs; ++i) + for (unsigned i = 0; i != NumArgs; ++i) consumedArgs[i] = epi.ConsumedArguments[i]; } } |