diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTContext.cpp | 105 | ||||
-rw-r--r-- | lib/AST/ASTImporter.cpp | 12 | ||||
-rw-r--r-- | lib/AST/ExprCXX.cpp | 19 | ||||
-rw-r--r-- | lib/AST/Type.cpp | 66 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 11 | ||||
-rw-r--r-- | lib/Rewrite/RewriteObjC.cpp | 111 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 17 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 95 | ||||
-rw-r--r-- | lib/Sema/SemaExceptionSpec.cpp | 35 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 22 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 24 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 15 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 49 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 29 |
15 files changed, 298 insertions, 323 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index ecba4a136f..a6b0861f02 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1141,7 +1141,7 @@ QualType ASTContext::getObjCGCQualType(QualType T, } static QualType getExtFunctionType(ASTContext& Context, QualType T, - const FunctionType::ExtInfo &Info) { + const FunctionType::ExtInfo &Info) { QualType ResultType; if (const PointerType *Pointer = T->getAs<PointerType>()) { QualType Pointee = Pointer->getPointeeType(); @@ -1183,15 +1183,11 @@ static QualType getExtFunctionType(ASTContext& Context, QualType T, Info); } else { const FunctionProtoType *FPT = cast<FunctionProtoType>(F); - ResultType - = Context.getFunctionType(FPT->getResultType(), FPT->arg_type_begin(), - FPT->getNumArgs(), FPT->isVariadic(), - FPT->getTypeQuals(), - FPT->hasExceptionSpec(), - FPT->hasAnyExceptionSpec(), - FPT->getNumExceptions(), - FPT->exception_begin(), - Info); + FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); + EPI.ExtInfo = Info; + ResultType = Context.getFunctionType(FPT->getResultType(), + FPT->arg_type_begin(), + FPT->getNumArgs(), EPI); } } else return T; @@ -1201,20 +1197,17 @@ static QualType getExtFunctionType(ASTContext& Context, QualType T, QualType ASTContext::getNoReturnType(QualType T, bool AddNoReturn) { FunctionType::ExtInfo Info = getFunctionExtInfo(T); - return getExtFunctionType(*this, T, - Info.withNoReturn(AddNoReturn)); + return getExtFunctionType(*this, T, Info.withNoReturn(AddNoReturn)); } QualType ASTContext::getCallConvType(QualType T, CallingConv CallConv) { FunctionType::ExtInfo Info = getFunctionExtInfo(T); - return getExtFunctionType(*this, T, - Info.withCallingConv(CallConv)); + return getExtFunctionType(*this, T, Info.withCallingConv(CallConv)); } QualType ASTContext::getRegParmType(QualType T, unsigned RegParm) { FunctionType::ExtInfo Info = getFunctionExtInfo(T); - return getExtFunctionType(*this, T, - Info.withRegParm(RegParm)); + return getExtFunctionType(*this, T, Info.withRegParm(RegParm)); } /// getComplexType - Return the uniqued reference to the type for a complex @@ -1763,20 +1756,13 @@ QualType ASTContext::getFunctionNoProtoType(QualType ResultTy, /// 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, bool isVariadic, - unsigned TypeQuals, bool hasExceptionSpec, - bool hasAnyExceptionSpec, unsigned NumExs, - const QualType *ExArray, - const FunctionType::ExtInfo &Info) { - - const CallingConv CallConv= Info.getCC(); +QualType ASTContext::getFunctionType(QualType ResultTy, + const QualType *ArgArray, unsigned NumArgs, + const FunctionProtoType::ExtProtoInfo &EPI) { // Unique functions, to guarantee there is only one function of a particular // structure. llvm::FoldingSetNodeID ID; - FunctionProtoType::Profile(ID, ResultTy, ArgArray, NumArgs, isVariadic, - TypeQuals, hasExceptionSpec, hasAnyExceptionSpec, - NumExs, ExArray, Info); + FunctionProtoType::Profile(ID, ResultTy, ArgArray, NumArgs, EPI); void *InsertPos = 0; if (FunctionProtoType *FTP = @@ -1784,11 +1770,13 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray, return QualType(FTP, 0); // Determine whether the type being created is already canonical or not. - bool isCanonical = !hasExceptionSpec && ResultTy.isCanonical(); + bool isCanonical = !EPI.HasExceptionSpec && ResultTy.isCanonical(); for (unsigned i = 0; i != NumArgs && isCanonical; ++i) if (!ArgArray[i].isCanonicalAsParam()) isCanonical = false; + const CallingConv CallConv = EPI.ExtInfo.getCC(); + // If this type isn't canonical, get the canonical version of it. // The exception spec is not part of the canonical type. QualType Canonical; @@ -1798,11 +1786,18 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray, for (unsigned i = 0; i != NumArgs; ++i) CanonicalArgs.push_back(getCanonicalParamType(ArgArray[i])); + FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI; + if (CanonicalEPI.HasExceptionSpec) { + CanonicalEPI.HasExceptionSpec = false; + CanonicalEPI.HasAnyExceptionSpec = false; + CanonicalEPI.NumExceptions = 0; + } + CanonicalEPI.ExtInfo + = CanonicalEPI.ExtInfo.withCallingConv(getCanonicalCallConv(CallConv)); + Canonical = getFunctionType(getCanonicalType(ResultTy), CanonicalArgs.data(), NumArgs, - isVariadic, TypeQuals, false, - false, 0, 0, - Info.withCallingConv(getCanonicalCallConv(CallConv))); + CanonicalEPI); // Get the new insert position for the node we care about. FunctionProtoType *NewIP = @@ -1813,13 +1808,11 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray, // FunctionProtoType objects are allocated with extra bytes after them // for two variable size arrays (for parameter and exception types) at the // end of them. - FunctionProtoType *FTP = - (FunctionProtoType*)Allocate(sizeof(FunctionProtoType) + - NumArgs*sizeof(QualType) + - NumExs*sizeof(QualType), TypeAlignment); - new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, isVariadic, - TypeQuals, hasExceptionSpec, hasAnyExceptionSpec, - ExArray, NumExs, Canonical, Info); + size_t Size = sizeof(FunctionProtoType) + + NumArgs * sizeof(QualType) + + EPI.NumExceptions * sizeof(QualType); + FunctionProtoType *FTP = (FunctionProtoType*) Allocate(Size, TypeAlignment); + new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, Canonical, EPI); Types.push_back(FTP); FunctionProtoTypes.InsertNode(FTP, InsertPos); return QualType(FTP, 0); @@ -4852,6 +4845,8 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, if (!isSameCallConv(lcc, rcc)) return QualType(); + FunctionType::ExtInfo einfo = FunctionType::ExtInfo(NoReturn, RegParm, lcc); + if (lproto && rproto) { // two C99 style function prototypes assert(!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec() && "C++ shouldn't be here"); @@ -4895,10 +4890,10 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, } if (allLTypes) return lhs; if (allRTypes) return rhs; - return getFunctionType(retType, types.begin(), types.size(), - lproto->isVariadic(), lproto->getTypeQuals(), - false, false, 0, 0, - FunctionType::ExtInfo(NoReturn, RegParm, lcc)); + + FunctionProtoType::ExtProtoInfo EPI = lproto->getExtProtoInfo(); + EPI.ExtInfo = einfo; + return getFunctionType(retType, types.begin(), types.size(), EPI); } if (lproto) allRTypes = false; @@ -4929,11 +4924,11 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, if (allLTypes) return lhs; if (allRTypes) return rhs; + + FunctionProtoType::ExtProtoInfo EPI = proto->getExtProtoInfo(); + EPI.ExtInfo = einfo; return getFunctionType(retType, proto->arg_type_begin(), - proto->getNumArgs(), proto->isVariadic(), - proto->getTypeQuals(), - false, false, 0, 0, - FunctionType::ExtInfo(NoReturn, RegParm, lcc)); + proto->getNumArgs(), EPI); } if (allLTypes) return lhs; @@ -5218,16 +5213,11 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) { // In either case, use OldReturnType to build the new function type. const FunctionType *F = LHS->getAs<FunctionType>(); if (const FunctionProtoType *FPT = cast<FunctionProtoType>(F)) { - FunctionType::ExtInfo Info = getFunctionExtInfo(LHS); + FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); + EPI.ExtInfo = getFunctionExtInfo(LHS); QualType ResultType = getFunctionType(OldReturnType, FPT->arg_type_begin(), - FPT->getNumArgs(), FPT->isVariadic(), - FPT->getTypeQuals(), - FPT->hasExceptionSpec(), - FPT->hasAnyExceptionSpec(), - FPT->getNumExceptions(), - FPT->exception_begin(), - Info); + FPT->getNumArgs(), EPI); return ResultType; } } @@ -5580,10 +5570,11 @@ QualType ASTContext::GetBuiltinType(unsigned Id, if (ArgTypes.size() == 0 && TypeStr[0] == '.') return getFunctionNoProtoType(ResType); + FunctionProtoType::ExtProtoInfo EPI; + EPI.Variadic = (TypeStr[0] == '.'); // FIXME: Should we create noreturn types? - return getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(), - TypeStr[0] == '.', 0, false, false, 0, 0, - FunctionType::ExtInfo()); + + return getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(), EPI); } GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) { diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 8415977349..cc485c47d9 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -1473,16 +1473,12 @@ QualType ASTNodeImporter::VisitFunctionProtoType(FunctionProtoType *T) { return QualType(); ExceptionTypes.push_back(ExceptionType); } + + FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo(); + EPI.Exceptions = ExceptionTypes.data(); return Importer.getToContext().getFunctionType(ToResultType, ArgTypes.data(), - ArgTypes.size(), - T->isVariadic(), - T->getTypeQuals(), - T->hasExceptionSpec(), - T->hasAnyExceptionSpec(), - ExceptionTypes.size(), - ExceptionTypes.data(), - T->getExtInfo()); + ArgTypes.size(), EPI); } QualType ASTNodeImporter::VisitTypedefType(TypedefType *T) { diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index b67e82453d..1c134608a5 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -185,6 +185,25 @@ PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); } +CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(ASTContext &Context, + Expr *Base, bool isArrow, SourceLocation OperatorLoc, + NestedNameSpecifier *Qualifier, SourceRange QualifierRange, + TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, + SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType) + : Expr(CXXPseudoDestructorExprClass, + Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, + FunctionProtoType::ExtProtoInfo())), + VK_RValue, OK_Ordinary, + /*isTypeDependent=*/(Base->isTypeDependent() || + (DestroyedType.getTypeSourceInfo() && + DestroyedType.getTypeSourceInfo()->getType()->isDependentType())), + /*isValueDependent=*/Base->isValueDependent()), + Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), + OperatorLoc(OperatorLoc), Qualifier(Qualifier), + QualifierRange(QualifierRange), + ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), + DestroyedType(DestroyedType) { } + QualType CXXPseudoDestructorExpr::getDestroyedType() const { if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) return TInfo->getType(); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 127613ed32..25aa5e0ea1 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1097,65 +1097,55 @@ llvm::StringRef FunctionType::getNameForCallConv(CallingConv CC) { return ""; } -FunctionProtoType::FunctionProtoType(QualType Result, const QualType *ArgArray, - unsigned numArgs, bool isVariadic, - unsigned typeQuals, bool hasExs, - bool hasAnyExs, const QualType *ExArray, - unsigned numExs, QualType Canonical, - const ExtInfo &Info) - : FunctionType(FunctionProto, Result, isVariadic, typeQuals, Canonical, - Result->isDependentType(), - Result->isVariablyModifiedType(), - Result->containsUnexpandedParameterPack(), - Info), - NumArgs(numArgs), NumExceptions(numExs), HasExceptionSpec(hasExs), - AnyExceptionSpec(hasAnyExs) +FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, + unsigned numArgs, QualType canonical, + const ExtProtoInfo &epi) + : FunctionType(FunctionProto, result, epi.Variadic, epi.TypeQuals, canonical, + result->isDependentType(), + result->isVariablyModifiedType(), + result->containsUnexpandedParameterPack(), + epi.ExtInfo), + NumArgs(numArgs), NumExceptions(epi.NumExceptions), + HasExceptionSpec(epi.HasExceptionSpec), + HasAnyExceptionSpec(epi.HasAnyExceptionSpec) { // Fill in the trailing argument array. - QualType *ArgInfo = reinterpret_cast<QualType*>(this+1); + QualType *argSlot = reinterpret_cast<QualType*>(this+1); for (unsigned i = 0; i != numArgs; ++i) { - if (ArgArray[i]->isDependentType()) + if (args[i]->isDependentType()) setDependent(); - if (ArgArray[i]->containsUnexpandedParameterPack()) + if (args[i]->containsUnexpandedParameterPack()) setContainsUnexpandedParameterPack(); - ArgInfo[i] = ArgArray[i]; + argSlot[i] = args[i]; } // Fill in the exception array. - QualType *Ex = ArgInfo + numArgs; - for (unsigned i = 0; i != numExs; ++i) - Ex[i] = ExArray[i]; + QualType *exnSlot = argSlot + numArgs; + for (unsigned i = 0, e = epi.NumExceptions; i != e; ++i) + exnSlot[i] = epi.Exceptions[i]; } void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result, - arg_type_iterator ArgTys, - unsigned NumArgs, bool isVariadic, - unsigned TypeQuals, bool hasExceptionSpec, - bool anyExceptionSpec, unsigned NumExceptions, - exception_iterator Exs, - FunctionType::ExtInfo Info) { + const QualType *ArgTys, unsigned NumArgs, + const ExtProtoInfo &epi) { ID.AddPointer(Result.getAsOpaquePtr()); for (unsigned i = 0; i != NumArgs; ++i) ID.AddPointer(ArgTys[i].getAsOpaquePtr()); - ID.AddInteger(isVariadic); - ID.AddInteger(TypeQuals); - ID.AddInteger(hasExceptionSpec); - if (hasExceptionSpec) { - ID.AddInteger(anyExceptionSpec); - for (unsigned i = 0; i != NumExceptions; ++i) - ID.AddPointer(Exs[i].getAsOpaquePtr()); + ID.AddBoolean(epi.Variadic); + ID.AddInteger(epi.TypeQuals); + if (epi.HasExceptionSpec) { + ID.AddBoolean(epi.HasAnyExceptionSpec); + for (unsigned i = 0; i != epi.NumExceptions; ++i) + ID.AddPointer(epi.Exceptions[i].getAsOpaquePtr()); } - Info.Profile(ID); + epi.ExtInfo.Profile(ID); } void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, getResultType(), arg_type_begin(), NumArgs, isVariadic(), - getTypeQuals(), hasExceptionSpec(), hasAnyExceptionSpec(), - getNumExceptions(), exception_begin(), - getExtInfo()); + Profile(ID, getResultType(), arg_type_begin(), NumArgs, getExtProtoInfo()); } QualType TypedefType::desugar() const { diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 7bd0c3da9e..8a0d78cc21 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -250,13 +250,14 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, Builder.SetInsertPoint(EntryBB); - QualType FnType = getContext().getFunctionType(RetTy, 0, 0, false, 0, - false, false, 0, 0, - /*FIXME?*/ - FunctionType::ExtInfo()); - // Emit subprogram debug descriptor. if (CGDebugInfo *DI = getDebugInfo()) { + // FIXME: what is going on here and why does it ignore all these + // interesting type properties? + QualType FnType = + getContext().getFunctionType(RetTy, 0, 0, + FunctionProtoType::ExtProtoInfo()); + DI->setLocation(StartLoc); DI->EmitFunctionStart(GD, FnType, CurFn, Builder); } diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 0d3881197b..539ee49a6c 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -450,6 +450,15 @@ namespace { To += From[i]; } } + + QualType getSimpleFunctionType(QualType result, + const QualType *args, + unsigned numArgs, + bool variadic = false) { + FunctionProtoType::ExtProtoInfo fpi; + fpi.Variadic = variadic; + return Context->getFunctionType(result, args, numArgs, fpi); + } }; // Helper function: create a CStyleCastExpr with trivial type source info. @@ -2352,11 +2361,8 @@ void RewriteObjC::SynthSelGetUidFunctionDecl() { IdentifierInfo *SelGetUidIdent = &Context->Idents.get("sel_registerName"); llvm::SmallVector<QualType, 16> ArgTys; ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); - QualType getFuncType = Context->getFunctionType(Context->getObjCSelType(), - &ArgTys[0], ArgTys.size(), - false /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType getFuncType = + getSimpleFunctionType(Context->getObjCSelType(), &ArgTys[0], ArgTys.size()); SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), SelGetUidIdent, getFuncType, 0, @@ -2451,11 +2457,8 @@ void RewriteObjC::SynthSuperContructorFunctionDecl() { assert(!argT.isNull() && "Can't find 'id' type"); ArgTys.push_back(argT); ArgTys.push_back(argT); - QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - false, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size()); SuperContructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2473,11 +2476,9 @@ void RewriteObjC::SynthMsgSendFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/); MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2498,11 +2499,9 @@ void RewriteObjC::SynthMsgSendSuperFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/); MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2520,11 +2519,9 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/); MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2547,11 +2544,9 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/); MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2569,11 +2564,9 @@ void RewriteObjC::SynthMsgSendFpretFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = Context->getFunctionType(Context->DoubleTy, - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType msgSendType = getSimpleFunctionType(Context->DoubleTy, + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/); MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2586,11 +2579,8 @@ void RewriteObjC::SynthGetClassFunctionDecl() { IdentifierInfo *getClassIdent = &Context->Idents.get("objc_getClass"); llvm::SmallVector<QualType, 16> ArgTys; ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); - QualType getClassType = Context->getFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - false /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType getClassType = getSimpleFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size()); GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), getClassIdent, getClassType, 0, @@ -2604,11 +2594,8 @@ void RewriteObjC::SynthGetSuperClassFunctionDecl() { &Context->Idents.get("class_getSuperclass"); llvm::SmallVector<QualType, 16> ArgTys; ArgTys.push_back(Context->getObjCClassType()); - QualType getClassType = Context->getFunctionType(Context->getObjCClassType(), - &ArgTys[0], ArgTys.size(), - false /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(), + &ArgTys[0], ArgTys.size()); GetSuperClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), getSuperClassIdent, @@ -2623,11 +2610,8 @@ void RewriteObjC::SynthGetMetaClassFunctionDecl() { IdentifierInfo *getClassIdent = &Context->Idents.get("objc_getMetaClass"); llvm::SmallVector<QualType, 16> ArgTys; ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); - QualType getClassType = Context->getFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - false /*isVariadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType getClassType = getSimpleFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size()); GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), getClassIdent, getClassType, 0, @@ -3075,12 +3059,10 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, CK_BitCast, DRE); // Now do the "normal" pointer to function cast. - QualType castType = Context->getFunctionType(returnType, - &ArgTypes[0], ArgTypes.size(), - // If we don't have a method decl, force a variadic cast. - Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType castType = + getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(), + // If we don't have a method decl, force a variadic cast. + Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true); castType = Context->getPointerType(castType); cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast, cast); @@ -3108,11 +3090,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, Context->getPointerType(Context->VoidTy), CK_BitCast, STDRE); // Now do the "normal" pointer to function cast. - castType = Context->getFunctionType(returnType, - &ArgTypes[0], ArgTypes.size(), - Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + castType = getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(), + Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false); castType = Context->getPointerType(castType); cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast, cast); @@ -4649,9 +4628,7 @@ QualType RewriteObjC::convertFunctionTypeOfBlocks(const FunctionType *FT) { // FIXME. Does this work if block takes no argument but has a return type // which is of block type? if (HasBlockType) - FuncType = Context->getFunctionType(Res, - &ArgTypes[0], ArgTypes.size(), false/*no variadic*/, 0, - false, false, 0, 0, FunctionType::ExtInfo()); + FuncType = getSimpleFunctionType(Res, &ArgTypes[0], ArgTypes.size()); else FuncType = QualType(FT, 0); return FuncType; } @@ -4719,10 +4696,8 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) { } } // Now do the pointer to function cast. - QualType PtrToFuncCastType = Context->getFunctionType(Exp->getType(), - &ArgTypes[0], ArgTypes.size(), false/*no variadic*/, 0, - false, false, 0, 0, - FunctionType::ExtInfo()); + QualType PtrToFuncCastType + = getSimpleFunctionType(Exp->getType(), &ArgTypes[0], ArgTypes.size()); PtrToFuncCastType = Context->getPointerType(PtrToFuncCastType); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 403838176c..66e517008c 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1285,10 +1285,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { OldProto->arg_type_end()); NewQType = Context.getFunctionType(NewFuncType->getResultType(), ParamTypes.data(), ParamTypes.size(), - OldProto->isVariadic(), - OldProto->getTypeQuals(), - false, false, 0, 0, - OldProto->getExtInfo()); + OldProto->getExtProtoInfo()); New->setType(NewQType); New->setHasInheritedPrototype(); @@ -1370,9 +1367,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { New->setType(Context.getFunctionType(MergedReturn, &ArgTypes[0], ArgTypes.size(), - OldProto->isVariadic(), 0, - false, false, 0, 0, - OldProto->getExtInfo())); + OldProto->getExtProtoInfo())); return MergeCompatibleFunctionDecls(New, Old); } @@ -4046,9 +4041,11 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // Turn this into a variadic function with no parameters. const FunctionType *FT = NewFD->getType()->getAs<FunctionType>(); - QualType R = Context.getFunctionType(FT->getResultType(), - 0, 0, true, 0, false, false, 0, 0, - FT->getExtInfo()); + FunctionProtoType::ExtProtoInfo EPI; + EPI.Variadic = true; + EPI.ExtInfo = FT->getExtInfo(); + + QualType R = Context.getFunctionType(FT->getResultType(), 0, 0, EPI); NewFD->setType(R); } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 3cfde26d24..eec80f0d5a 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2851,20 +2851,21 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R, if (FTI.TypeQuals & Qualifiers::Restrict) Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor) << "restrict" << SourceRange(D.getIdentifierLoc()); + D.setInvalidType(); } // Rebuild the function type "R" without any type qualifiers (in // case any of the errors above fired) and with "void" as the // return type, since constructors don't have return types. const FunctionProtoType *Proto = R->getAs<FunctionProtoType>(); + if (Proto->getResultType() == Context.VoidTy && !D.isInvalidType()) + return R; + + FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo(); + EPI.TypeQuals = 0; + return Context.getFunctionType(Context.VoidTy, Proto->arg_type_begin(), - Proto->getNumArgs(), - Proto->isVariadic(), 0, - Proto->hasExceptionSpec(), - Proto->hasAnyExceptionSpec(), - Proto->getNumExceptions(), - Proto->exception_begin(), - Proto->getExtInfo()); + Proto->getNumArgs(), EPI); } /// CheckConstructor - Checks a fully-formed constructor for @@ -3022,16 +3023,14 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R, // parameters (in case any of the errors above fired) and with // "void" as the return type, since destructors don't have return // types. + if (!D.isInvalidType()) + return R; + const FunctionProtoType *Proto = R->getAs<FunctionProtoType>(); - if (!Proto) - return QualType(); - - return Context.getFunctionType(Context.VoidTy, 0, 0, false, 0, - Proto->hasExceptionSpec(), - Proto->hasAnyExceptionSpec(), - Proto->getNumExceptions(), - Proto->exception_begin(), - Proto->getExtInfo()); + FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo(); + EPI.Variadic = false; + EPI.TypeQuals = 0; + return Context.getFunctionType(Context.VoidTy, 0, 0, EPI); } /// CheckConversionDeclarator - Called by ActOnDeclarator to check the @@ -3111,15 +3110,8 @@ void Sema::CheckConv |