diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 77 | ||||
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 14 | ||||
-rw-r--r-- | clang/lib/AST/Type.cpp | 12 | ||||
-rw-r--r-- | clang/lib/AST/TypePrinter.cpp | 6 |
4 files changed, 57 insertions, 52 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f8f626a1e4d..00a7987a2b2 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1097,14 +1097,12 @@ QualType ASTContext::getObjCGCQualType(QualType T, return getExtQualType(TypeNode, Quals); } -static QualType getNoReturnCallConvType(ASTContext& Context, QualType T, - bool AddNoReturn, - CallingConv CallConv) { +static QualType getExtFunctionType(ASTContext& Context, QualType T, + const FunctionType::ExtInfo &Info) { QualType ResultType; if (const PointerType *Pointer = T->getAs<PointerType>()) { QualType Pointee = Pointer->getPointeeType(); - ResultType = getNoReturnCallConvType(Context, Pointee, AddNoReturn, - CallConv); + ResultType = getExtFunctionType(Context, Pointee, Info); if (ResultType == Pointee) return T; @@ -1112,19 +1110,18 @@ static QualType getNoReturnCallConvType(ASTContext& Context, QualType T, } else if (const BlockPointerType *BlockPointer = T->getAs<BlockPointerType>()) { QualType Pointee = BlockPointer->getPointeeType(); - ResultType = getNoReturnCallConvType(Context, Pointee, AddNoReturn, - CallConv); + ResultType = getExtFunctionType(Context, Pointee, Info); if (ResultType == Pointee) return T; ResultType = Context.getBlockPointerType(ResultType); } else if (const FunctionType *F = T->getAs<FunctionType>()) { - if (F->getNoReturnAttr() == AddNoReturn && F->getCallConv() == CallConv) + if (F->getExtInfo() == Info) return T; if (const FunctionNoProtoType *FNPT = dyn_cast<FunctionNoProtoType>(F)) { ResultType = Context.getFunctionNoProtoType(FNPT->getResultType(), - AddNoReturn, CallConv); + Info); } else { const FunctionProtoType *FPT = cast<FunctionProtoType>(F); ResultType @@ -1135,7 +1132,7 @@ static QualType getNoReturnCallConvType(ASTContext& Context, QualType T, FPT->hasAnyExceptionSpec(), FPT->getNumExceptions(), FPT->exception_begin(), - AddNoReturn, CallConv); + Info); } } else return T; @@ -1144,11 +1141,15 @@ static QualType getNoReturnCallConvType(ASTContext& Context, QualType T, } QualType ASTContext::getNoReturnType(QualType T, bool AddNoReturn) { - return getNoReturnCallConvType(*this, T, AddNoReturn, T->getCallConv()); + FunctionType::ExtInfo Info = getFunctionExtInfo(*T); + return getExtFunctionType(*this, T, + Info.withNoReturn(AddNoReturn)); } QualType ASTContext::getCallConvType(QualType T, CallingConv CallConv) { - return getNoReturnCallConvType(*this, T, T->getNoReturnAttr(), CallConv); + FunctionType::ExtInfo Info = getFunctionExtInfo(*T); + return getExtFunctionType(*this, T, + Info.withCallingConv(CallConv)); } /// getComplexType - Return the uniqued reference to the type for a complex @@ -1606,12 +1607,13 @@ QualType ASTContext::getDependentSizedExtVectorType(QualType vecType, /// getFunctionNoProtoType - Return a K&R style C function type like 'int()'. /// -QualType ASTContext::getFunctionNoProtoType(QualType ResultTy, bool NoReturn, - CallingConv CallConv) { +QualType ASTContext::getFunctionNoProtoType(QualType ResultTy, + 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; - FunctionNoProtoType::Profile(ID, ResultTy, NoReturn, CallConv); + FunctionNoProtoType::Profile(ID, ResultTy, Info); void *InsertPos = 0; if (FunctionNoProtoType *FT = @@ -1621,8 +1623,9 @@ QualType ASTContext::getFunctionNoProtoType(QualType ResultTy, bool NoReturn, QualType Canonical; if (!ResultTy.isCanonical() || getCanonicalCallConv(CallConv) != CallConv) { - Canonical = getFunctionNoProtoType(getCanonicalType(ResultTy), NoReturn, - getCanonicalCallConv(CallConv)); + Canonical = + getFunctionNoProtoType(getCanonicalType(ResultTy), + Info.withCallingConv(getCanonicalCallConv(CallConv))); // Get the new insert position for the node we care about. FunctionNoProtoType *NewIP = @@ -1631,7 +1634,7 @@ QualType ASTContext::getFunctionNoProtoType(QualType ResultTy, bool NoReturn, } FunctionNoProtoType *New = new (*this, TypeAlignment) - FunctionNoProtoType(ResultTy, Canonical, NoReturn, CallConv); + FunctionNoProtoType(ResultTy, Canonical, Info); Types.push_back(New); FunctionNoProtoTypes.InsertNode(New, InsertPos); return QualType(New, 0); @@ -1643,14 +1646,15 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray, unsigned NumArgs, bool isVariadic, unsigned TypeQuals, bool hasExceptionSpec, bool hasAnyExceptionSpec, unsigned NumExs, - const QualType *ExArray, bool NoReturn, - CallingConv CallConv) { + 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, isVariadic, TypeQuals, hasExceptionSpec, hasAnyExceptionSpec, - NumExs, ExArray, NoReturn, CallConv); + NumExs, ExArray, Info); void *InsertPos = 0; if (FunctionProtoType *FTP = @@ -1675,8 +1679,8 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray, Canonical = getFunctionType(getCanonicalType(ResultTy), CanonicalArgs.data(), NumArgs, isVariadic, TypeQuals, false, - false, 0, 0, NoReturn, - getCanonicalCallConv(CallConv)); + false, 0, 0, + Info.withCallingConv(getCanonicalCallConv(CallConv))); // Get the new insert position for the node we care about. FunctionProtoType *NewIP = @@ -1693,7 +1697,7 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray, NumExs*sizeof(QualType), TypeAlignment); new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, isVariadic, TypeQuals, hasExceptionSpec, hasAnyExceptionSpec, - ExArray, NumExs, Canonical, NoReturn, CallConv); + ExArray, NumExs, Canonical, Info); Types.push_back(FTP); FunctionProtoTypes.InsertNode(FTP, InsertPos); return QualType(FTP, 0); @@ -4304,13 +4308,15 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, if (getCanonicalType(retType) != getCanonicalType(rbase->getResultType())) allRTypes = false; // FIXME: double check this - bool NoReturn = lbase->getNoReturnAttr() || rbase->getNoReturnAttr(); - if (NoReturn != lbase->getNoReturnAttr()) + FunctionType::ExtInfo lbaseInfo = lbase->getExtInfo(); + FunctionType::ExtInfo rbaseInfo = rbase->getExtInfo(); + bool NoReturn = lbaseInfo.getNoReturn() || rbaseInfo.getNoReturn(); + if (NoReturn != lbaseInfo.getNoReturn()) allLTypes = false; - if (NoReturn != rbase->getNoReturnAttr()) + if (NoReturn != rbaseInfo.getNoReturn()) allRTypes = false; - CallingConv lcc = lbase->getCallConv(); - CallingConv rcc = rbase->getCallConv(); + CallingConv lcc = lbaseInfo.getCC(); + CallingConv rcc = rbaseInfo.getCC(); // Compatible functions must have compatible calling conventions if (!isSameCallConv(lcc, rcc)) return QualType(); @@ -4349,7 +4355,8 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, if (allRTypes) return rhs; return getFunctionType(retType, types.begin(), types.size(), lproto->isVariadic(), lproto->getTypeQuals(), - false, false, 0, 0, NoReturn, lcc); + false, false, 0, 0, + FunctionType::ExtInfo(NoReturn, lcc)); } if (lproto) allRTypes = false; @@ -4382,13 +4389,15 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, if (allRTypes) return rhs; return getFunctionType(retType, proto->arg_type_begin(), proto->getNumArgs(), proto->isVariadic(), - proto->getTypeQuals(), - false, false, 0, 0, NoReturn, lcc); + proto->getTypeQuals(), + false, false, 0, 0, + FunctionType::ExtInfo(NoReturn, lcc)); } if (allLTypes) return lhs; if (allRTypes) return rhs; - return getFunctionNoProtoType(retType, NoReturn, lcc); + FunctionType::ExtInfo Info(NoReturn, lcc); + return getFunctionNoProtoType(retType, Info); } QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, @@ -4892,7 +4901,7 @@ QualType ASTContext::GetBuiltinType(unsigned id, // FIXME: Should we create noreturn types? return getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(), TypeStr[0] == '.', 0, false, false, 0, 0, - false, CC_Default); + FunctionType::ExtInfo()); } QualType diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index dd2528a6b3b..9e789bb554b 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -484,10 +484,8 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, Function1->getResultType(), Function2->getResultType())) return false; - if (Function1->getNoReturnAttr() != Function2->getNoReturnAttr()) - return false; - if (Function1->getCallConv() != Function2->getCallConv()) - return false; + if (Function1->getExtInfo() != Function2->getExtInfo()) + return false; break; } @@ -1200,10 +1198,9 @@ QualType ASTNodeImporter::VisitFunctionNoProtoType(FunctionNoProtoType *T) { QualType ToResultType = Importer.Import(T->getResultType()); if (ToResultType.isNull()) return QualType(); - + return Importer.getToContext().getFunctionNoProtoType(ToResultType, - T->getNoReturnAttr(), - T->getCallConv()); + T->getExtInfo()); } QualType ASTNodeImporter::VisitFunctionProtoType(FunctionProtoType *T) { @@ -1241,8 +1238,7 @@ QualType ASTNodeImporter::VisitFunctionProtoType(FunctionProtoType *T) { T->hasAnyExceptionSpec(), ExceptionTypes.size(), ExceptionTypes.data(), - T->getNoReturnAttr(), - T->getCallConv()); + T->getExtInfo()); } QualType ASTNodeImporter::VisitTypedefType(TypedefType *T) { diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 22dd2ecd643..b3675203d7f 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -827,8 +827,8 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result, unsigned NumArgs, bool isVariadic, unsigned TypeQuals, bool hasExceptionSpec, bool anyExceptionSpec, unsigned NumExceptions, - exception_iterator Exs, bool NoReturn, - CallingConv CallConv) { + exception_iterator Exs, + const FunctionType::ExtInfo &Info) { ID.AddPointer(Result.getAsOpaquePtr()); for (unsigned i = 0; i != NumArgs; ++i) ID.AddPointer(ArgTys[i].getAsOpaquePtr()); @@ -840,15 +840,15 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result, for (unsigned i = 0; i != NumExceptions; ++i) ID.AddPointer(Exs[i].getAsOpaquePtr()); } - ID.AddInteger(NoReturn); - ID.AddInteger(CallConv); + ID.AddInteger(Info.getNoReturn()); + ID.AddInteger(Info.getCC()); } void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getResultType(), arg_type_begin(), NumArgs, isVariadic(), getTypeQuals(), hasExceptionSpec(), hasAnyExceptionSpec(), - getNumExceptions(), exception_begin(), getNoReturnAttr(), - getCallConv()); + getNumExceptions(), exception_begin(), + getExtInfo()); } void ObjCObjectPointerType::Profile(llvm::FoldingSetNodeID &ID, diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index 0c4896decf8..d1893cc6111 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -282,7 +282,8 @@ void TypePrinter::PrintFunctionProto(const FunctionProtoType *T, S += ")"; - switch(T->getCallConv()) { + FunctionType::ExtInfo Info = T->getExtInfo(); + switch(Info.getCC()) { case CC_Default: default: break; case CC_C: @@ -295,7 +296,7 @@ void TypePrinter::PrintFunctionProto(const FunctionProtoType *T, S += " __attribute__((fastcall))"; break; } - if (T->getNoReturnAttr()) + if (Info.getNoReturn()) S += " __attribute__((noreturn))"; @@ -819,4 +820,3 @@ void QualType::getAsStringInternal(std::string &S, TypePrinter Printer(Policy); Printer.Print(*this, S); } - |