diff options
-rw-r--r-- | include/clang/AST/ASTContext.h | 13 | ||||
-rw-r--r-- | include/clang/AST/ExprCXX.h | 17 | ||||
-rw-r--r-- | include/clang/AST/Type.h | 61 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 2 | ||||
-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 |
19 files changed, 367 insertions, 347 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 70a852d9dd..745b6a38db 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -626,11 +626,14 @@ public: return getFunctionNoProtoType(ResultTy, FunctionType::ExtInfo()); } - /// getFunctionType - Return a normal function type with a typed - /// argument list. - QualType getFunctionType(QualType ResultTy, - const QualType *Args, unsigned NumArgs, - const FunctionProtoType::ExtProtoInfo &EPI); + /// getFunctionType - Return a normal function type with a typed argument + /// list. isVariadic indicates whether the argument list includes '...'. + QualType 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); /// getTypeDeclType - Return the unique reference to the type for /// the specified type declaration. diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 6b18561424..a822bcaffe 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -1278,7 +1278,22 @@ public: TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, SourceLocation TildeLoc, - PseudoDestructorTypeStorage DestroyedType); + PseudoDestructorTypeStorage DestroyedType) + : Expr(CXXPseudoDestructorExprClass, + Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, + false, 0, false, + false, 0, 0, + FunctionType::ExtInfo())), + 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) { } explicit CXXPseudoDestructorExpr(EmptyShell Shell) : Expr(CXXPseudoDestructorExprClass, Shell), diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 686331f44c..ba588ec1aa 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -925,8 +925,8 @@ protected: /// regparm and the calling convention. unsigned ExtInfo : 8; - /// Whether the function is variadic. Only used by FunctionProtoType. - unsigned Variadic : 1; + /// A bit to be used by the subclass. + unsigned SubclassInfo : 1; /// TypeQuals - Used only by FunctionProtoType, put here to pack with the /// other bitfields. @@ -2196,13 +2196,13 @@ class FunctionType : public Type { return ExtInfo((Bits & ~CallConvMask) | (unsigned) cc); } - void Profile(llvm::FoldingSetNodeID &ID) const { + void Profile(llvm::FoldingSetNodeID &ID) { ID.AddInteger(Bits); } }; protected: - FunctionType(TypeClass tc, QualType res, bool variadic, + FunctionType(TypeClass tc, QualType res, bool SubclassInfo, unsigned typeQuals, QualType Canonical, bool Dependent, bool VariablyModified, bool ContainsUnexpandedParameterPack, ExtInfo Info) @@ -2210,10 +2210,10 @@ protected: ContainsUnexpandedParameterPack), ResultType(res) { FunctionTypeBits.ExtInfo = Info.Bits; - FunctionTypeBits.Variadic = variadic; + FunctionTypeBits.SubclassInfo = SubclassInfo; FunctionTypeBits.TypeQuals = typeQuals; } - bool isVariadic() const { return FunctionTypeBits.Variadic; } + bool getSubClassData() const { return FunctionTypeBits.SubclassInfo; } unsigned getTypeQuals() const { return FunctionTypeBits.TypeQuals; } public: @@ -2276,23 +2276,6 @@ public: /// exception specification, but this specification is not part of the canonical /// type. class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode { -public: - /// ExtProtoInfo - Extra information about a function prototype. - struct ExtProtoInfo { - ExtProtoInfo() : - Variadic(false), HasExceptionSpec(false), HasAnyExceptionSpec(false), - TypeQuals(0), NumExceptions(0), Exceptions(0) {} - - FunctionType::ExtInfo ExtInfo; - bool Variadic; - bool HasExceptionSpec; - bool HasAnyExceptionSpec; - unsigned char TypeQuals; - unsigned NumExceptions; - const QualType *Exceptions; - }; - -private: /// \brief Determine whether there are any argument types that /// contain an unexpanded parameter pack. static bool containsAnyUnexpandedParameterPack(const QualType *ArgArray, @@ -2304,8 +2287,11 @@ private: return false; } - FunctionProtoType(QualType result, const QualType *args, unsigned numArgs, - QualType canonical, const ExtProtoInfo &epi); + 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); /// NumArgs - The number of arguments this function has, not counting '...'. unsigned NumArgs : 20; @@ -2316,8 +2302,8 @@ private: /// HasExceptionSpec - Whether this function has an exception spec at all. unsigned HasExceptionSpec : 1; - /// HasAnyExceptionSpec - Whether this function has a throw(...) spec. - unsigned HasAnyExceptionSpec : 1; + /// AnyExceptionSpec - Whether this function has a throw(...) spec. + unsigned AnyExceptionSpec : 1; /// ArgInfo - There is an variable size array after the class in memory that /// holds the argument types. @@ -2334,20 +2320,8 @@ public: return arg_type_begin()[i]; } - ExtProtoInfo getExtProtoInfo() const { - ExtProtoInfo EPI; - EPI.ExtInfo = getExtInfo(); - EPI.Variadic = isVariadic(); - EPI.HasExceptionSpec = hasExceptionSpec(); - EPI.HasAnyExceptionSpec = hasAnyExceptionSpec(); - EPI.TypeQuals = static_cast<unsigned char>(getTypeQuals()); - EPI.NumExceptions = NumExceptions; - EPI.Exceptions = exception_begin(); - return EPI; - } - bool hasExceptionSpec() const { return HasExceptionSpec; } - bool hasAnyExceptionSpec() const { return HasAnyExceptionSpec; } + bool hasAnyExceptionSpec() const { return AnyExceptionSpec; } unsigned getNumExceptions() const { return NumExceptions; } QualType getExceptionType(unsigned i) const { assert(i < NumExceptions && "Invalid exception number!"); @@ -2358,7 +2332,7 @@ public: getNumExceptions() == 0; } - using FunctionType::isVariadic; + bool isVariadic() const { return getSubClassData(); } unsigned getTypeQuals() const { return FunctionType::getTypeQuals(); } typedef const QualType *arg_type_iterator; @@ -2387,7 +2361,10 @@ public: void Profile(llvm::FoldingSetNodeID &ID); static void Profile(llvm::FoldingSetNodeID &ID, QualType Result, arg_type_iterator ArgTys, unsigned NumArgs, - const ExtProtoInfo &EPI); + bool isVariadic, unsigned TypeQuals, + bool hasExceptionSpec, bool anyExceptionSpec, + unsigned NumExceptions, exception_iterator Exs, + ExtInfo ExtInfo); }; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 22e395cf96..dd8ae51e90 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -615,7 +615,7 @@ public: QualType *ParamTypes, unsigned NumParamTypes, bool Variadic, unsigned Quals, SourceLocation Loc, DeclarationName Entity, - FunctionType::ExtInfo Info); + const FunctionType::ExtInfo &Info); QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity); diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a6b0861f02..ecba4a136f 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,11 +1183,15 @@ static QualType getExtFunctionType(ASTContext& Context, QualType T, Info); } else { const FunctionProtoType *FPT = cast<FunctionProtoType>(F); - FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); - EPI.ExtInfo = Info; - ResultType = Context.getFunctionType(FPT->getResultType(), - FPT->arg_type_begin(), - FPT->getNumArgs(), EPI); + 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); } } else return T; @@ -1197,17 +1201,20 @@ 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 @@ -1756,13 +1763,20 @@ 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, - const FunctionProtoType::ExtProtoInfo &EPI) { +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(); // Unique functions, to guarantee there is only one function of a particular // structure. llvm::FoldingSetNodeID ID; - FunctionProtoType::Profile(ID, ResultTy, ArgArray, NumArgs, EPI); + FunctionProtoType::Profile(ID, ResultTy, ArgArray, NumArgs, isVariadic, + TypeQuals, hasExceptionSpec, hasAnyExceptionSpec, + NumExs, ExArray, Info); void *InsertPos = 0; if (FunctionProtoType *FTP = @@ -1770,13 +1784,11 @@ QualType ASTContext::getFunctionType(QualType ResultTy, return QualType(FTP, 0); // Determine whether the type being created is already canonical or not. - bool isCanonical = !EPI.HasExceptionSpec && ResultTy.isCanonical(); + bool isCanonical = !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; @@ -1786,18 +1798,11 @@ QualType ASTContext::getFunctionType(QualType ResultTy, 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, - CanonicalEPI); + isVariadic, TypeQuals, false, + false, 0, 0, + Info.withCallingConv(getCanonicalCallConv(CallConv))); // Get the new insert position for the node we care about. FunctionProtoType *NewIP = @@ -1808,11 +1813,13 @@ QualType ASTContext::getFunctionType(QualType ResultTy, // FunctionProtoType objects are allocated with extra bytes after them // for two variable size arrays (for parameter and exception types) at the // end of them. - 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); + 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); Types.push_back(FTP); FunctionProtoTypes.InsertNode(FTP, InsertPos); return QualType(FTP, 0); @@ -4845,8 +4852,6 @@ 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"); @@ -4890,10 +4895,10 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, } if (allLTypes) return lhs; if (allRTypes) return rhs; - - FunctionProtoType::ExtProtoInfo EPI = lproto->getExtProtoInfo(); - EPI.ExtInfo = einfo; - return getFunctionType(retType, types.begin(), types.size(), EPI); + return getFunctionType(retType, types.begin(), types.size(), + lproto->isVariadic(), lproto->getTypeQuals(), + false, false, 0, 0, + FunctionType::ExtInfo(NoReturn, RegParm, lcc)); } if (lproto) allRTypes = false; @@ -4924,11 +4929,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(), EPI); + proto->getNumArgs(), proto->isVariadic(), + proto->getTypeQuals(), + false, false, 0, 0, + FunctionType::ExtInfo(NoReturn, RegParm, lcc)); } if (allLTypes) return lhs; @@ -5213,11 +5218,16 @@ 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)) { - FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); - EPI.ExtInfo = getFunctionExtInfo(LHS); + FunctionType::ExtInfo Info = getFunctionExtInfo(LHS); QualType ResultType = getFunctionType(OldReturnType, FPT->arg_type_begin(), - FPT->getNumArgs(), EPI); + FPT->getNumArgs(), FPT->isVariadic(), + FPT->getTypeQuals(), + FPT->hasExceptionSpec(), + FPT->hasAnyExceptionSpec(), + FPT->getNumExceptions(), + FPT->exception_begin(), + Info); return ResultType; } } @@ -5570,11 +5580,10 @@ 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(), EPI); + return getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(), + TypeStr[0] == '.', 0, false, false, 0, 0, + FunctionType::ExtInfo()); } GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) { diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index cc485c47d9..8415977349 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -1473,12 +1473,16 @@ 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(), EPI); + ArgTypes.size(), + T->isVariadic(), + T->getTypeQuals(), + T->hasExceptionSpec(), + T->hasAnyExceptionSpec(), + ExceptionTypes.size(), + ExceptionTypes.data(), + T->getExtInfo()); } QualType ASTNodeImporter::VisitTypedefType(TypedefType *T) { diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 1c134608a5..b67e82453d 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -185,25 +185,6 @@ 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 25aa5e0ea1..127613ed32 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1097,55 +1097,65 @@ llvm::StringRef FunctionType::getNameForCallConv(CallingConv CC) { return ""; } -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) +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) { // Fill in the trailing argument array. - QualType *argSlot = reinterpret_cast<QualType*>(this+1); + QualType *ArgInfo = reinterpret_cast<QualType*>(this+1); for (unsigned i = 0; i != numArgs; ++i) { - if (args[i]->isDependentType()) + if (ArgArray[i]->isDependentType()) setDependent(); - if (args[i]->containsUnexpandedParameterPack()) + if (ArgArray[i]->containsUnexpandedParameterPack()) setContainsUnexpandedParameterPack(); - argSlot[i] = args[i]; + ArgInfo[i] = ArgArray[i]; } // Fill in the exception array. - QualType *exnSlot = argSlot + numArgs; - for (unsigned i = 0, e = epi.NumExceptions; i != e; ++i) - exnSlot[i] = epi.Exceptions[i]; + QualType *Ex = ArgInfo + numArgs; + for (unsigned i = 0; i != numExs; ++i) + Ex[i] = ExArray[i]; } void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result, - const QualType *ArgTys, unsigned NumArgs, - const ExtProtoInfo &epi) { + arg_type_iterator ArgTys, + unsigned NumArgs, bool isVariadic, + unsigned TypeQuals, bool hasExceptionSpec, + bool anyExceptionSpec, unsigned NumExceptions, + exception_iterator Exs, + FunctionType::ExtInfo Info) { ID.AddPointer(Result.getAsOpaquePtr()); for (unsigned i = 0; i != NumArgs; ++i) ID.AddPointer(ArgTys[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()); + 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()); } - epi.ExtInfo.Profile(ID); + Info.Profile(ID); } void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, getResultType(), arg_type_begin(), NumArgs, getExtProtoInfo()); + Profile(ID, getResultType(), arg_type_begin(), NumArgs, isVariadic(), + getTypeQuals(), hasExceptionSpec(), hasAnyExceptionSpec(), + getNumExceptions(), exception_begin(), + getExtInfo()); } QualType TypedefType::desugar() const { diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 8a0d78cc21..7bd0c3da9e 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -250,14 +250,13 @@ 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 539ee49a6c..0d3881197b 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -450,15 +450,6 @@ 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. @@ -2361,8 +2352,11 @@ 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 = - getSimpleFunctionType(Context->getObjCSelType(), &ArgTys[0], ArgTys.size()); + QualType getFuncType = Context->getFunctionType(Context->getObjCSelType(), + &ArgTys[0], ArgTys.size(), + false /*isVariadic*/, 0, + false, false, 0, 0, + FunctionType::ExtInfo()); SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), SelGetUidIdent, getFuncType, 0, @@ -2457,8 +2451,11 @@ void RewriteObjC::SynthSuperContructorFunctionDecl() { assert(!argT.isNull() && "Can't find 'id' type"); ArgTys.push_back(argT); ArgTys.push_back(argT); - QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size()); + QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + false, 0, + false, false, 0, 0, + FunctionType::ExtInfo()); SuperContructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2476,9 +2473,11 @@ void RewriteObjC::SynthMsgSendFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/); + QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/, 0, + false, false, 0, 0, + FunctionType::ExtInfo()); MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2499,9 +2498,11 @@ void RewriteObjC::SynthMsgSendSuperFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/); + QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/, 0, + false, false, 0, 0, + FunctionType::ExtInfo()); MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2519,9 +2520,11 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/); + QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/, 0, + false, false, 0, 0, + FunctionType::ExtInfo()); MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, @@ -2544,9 +2547,11 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), - &ArgTys[0], ArgTys.size(), - true /*isVariadic*/); + QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(), + &ArgTys[0], ArgTys.size(), + true /*isVariadic*/, 0, + false, false, 0, 0, + FunctionType::ExtInfo()); |