diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-03-05 22:42:26 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-03-05 22:42:26 +0000 |
commit | 06bfa84588658d721094f383d6950e75100c4c4c (patch) | |
tree | c4f20d2cb081009c576eaaea1963474272a620d8 | |
parent | 6e5d319b671dbb0ecf70619834aa23c853d17621 (diff) | |
download | clang-06bfa84588658d721094f383d6950e75100c4c4c.tar.gz |
Propagate new-style exception spec information to ExtProtoInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127112 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Type.h | 13 | ||||
-rw-r--r-- | include/clang/Sema/DeclSpec.h | 10 | ||||
-rw-r--r-- | lib/AST/ASTContext.cpp | 9 | ||||
-rw-r--r-- | lib/AST/Type.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 22 | ||||
-rw-r--r-- | lib/Sema/SemaExceptionSpec.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 9 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 6 |
11 files changed, 45 insertions, 50 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 9b177cceed..c194e7baa9 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_AST_TYPE_H #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/ExceptionSpecificationType.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/Linkage.h" #include "clang/Basic/PartialDiagnostic.h" @@ -2403,17 +2404,17 @@ public: /// ExtProtoInfo - Extra information about a function prototype. struct ExtProtoInfo { ExtProtoInfo() : - Variadic(false), HasExceptionSpec(false), HasAnyExceptionSpec(false), - TypeQuals(0), RefQualifier(RQ_None), NumExceptions(0), Exceptions(0) {} + Variadic(false), ExceptionSpecType(EST_None), TypeQuals(0), + RefQualifier(RQ_None), NumExceptions(0), Exceptions(0), NoexceptExpr(0) {} FunctionType::ExtInfo ExtInfo; bool Variadic; - bool HasExceptionSpec; - bool HasAnyExceptionSpec; + ExceptionSpecificationType ExceptionSpecType; unsigned char TypeQuals; RefQualifierKind RefQualifier; unsigned NumExceptions; const QualType *Exceptions; + Expr *NoexceptExpr; }; private: @@ -2462,8 +2463,8 @@ public: ExtProtoInfo EPI; EPI.ExtInfo = getExtInfo(); EPI.Variadic = isVariadic(); - EPI.HasExceptionSpec = hasExceptionSpec(); - EPI.HasAnyExceptionSpec = hasAnyExceptionSpec(); + EPI.ExceptionSpecType = hasExceptionSpec() ? + (hasAnyExceptionSpec() ? EST_DynamicAny : EST_Dynamic) : EST_None; EPI.TypeQuals = static_cast<unsigned char>(getTypeQuals()); EPI.RefQualifier = getRefQualifier(); EPI.NumExceptions = NumExceptions; diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 164dac096d..b7a6499502 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -24,6 +24,7 @@ #include "clang/Sema/Ownership.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/Lex/Token.h" +#include "clang/Basic/ExceptionSpecificationType.h" #include "clang/Basic/OperatorKinds.h" #include "clang/Basic/Specifiers.h" #include "llvm/ADT/SmallVector.h" @@ -907,15 +908,6 @@ public: /// parsing. typedef llvm::SmallVector<Token, 4> CachedTokens; -/// \brief The various types of exception specifications that exist in C++0x. -enum ExceptionSpecificationType { - EST_None, ///< no exception specification - EST_Dynamic, ///< throw() or throw(T1, T2) - EST_DynamicAny, ///< Microsoft throw(...) extension - EST_BasicNoexcept, ///< noexcept - EST_ComputedNoexcept ///< noexcept(expression) -}; - /// DeclaratorChunk - One instance of this struct is used for each type in a /// declarator that is parsed. /// diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 3fd58ce9fd..f9cc06987b 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1913,7 +1913,7 @@ 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= EPI.ExceptionSpecType == EST_None && ResultTy.isCanonical(); for (unsigned i = 0; i != NumArgs && isCanonical; ++i) if (!ArgArray[i].isCanonicalAsParam()) isCanonical = false; @@ -1932,11 +1932,8 @@ ASTContext::getFunctionType(QualType ResultTy, CanonicalArgs.push_back(getCanonicalParamType(ArgArray[i])); FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI; - if (CanonicalEPI.HasExceptionSpec) { - CanonicalEPI.HasExceptionSpec = false; - CanonicalEPI.HasAnyExceptionSpec = false; - CanonicalEPI.NumExceptions = 0; - } + CanonicalEPI.ExceptionSpecType = EST_None; + CanonicalEPI.NumExceptions = 0; CanonicalEPI.ExtInfo = CanonicalEPI.ExtInfo.withCallingConv(getCanonicalCallConv(CallConv)); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index cde865f5b9..eea08f6242 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1173,8 +1173,8 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, result->containsUnexpandedParameterPack(), epi.ExtInfo), NumArgs(numArgs), NumExceptions(epi.NumExceptions), - HasExceptionSpec(epi.HasExceptionSpec), - HasAnyExceptionSpec(epi.HasAnyExceptionSpec) + HasExceptionSpec(isDynamicExceptionSpec(epi.ExceptionSpecType)), + HasAnyExceptionSpec(epi.ExceptionSpecType == EST_DynamicAny) { // Fill in the trailing argument array. QualType *argSlot = reinterpret_cast<QualType*>(this+1); @@ -1218,8 +1218,8 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result, ID.AddBoolean(epi.Variadic); ID.AddInteger(epi.TypeQuals); ID.AddInteger(epi.RefQualifier); - if (epi.HasExceptionSpec) { - ID.AddBoolean(epi.HasAnyExceptionSpec); + if (isDynamicExceptionSpec(epi.ExceptionSpecType)) { + ID.AddBoolean(epi.ExceptionSpecType == EST_DynamicAny); for (unsigned i = 0; i != epi.NumExceptions; ++i) ID.AddPointer(epi.Exceptions[i].getAsOpaquePtr()); } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 623e72f299..ba929587ae 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -4712,11 +4712,12 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor( } FunctionProtoType::ExtProtoInfo EPI; - EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification(); - EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification(); + EPI.ExceptionSpecType = ExceptSpec.hasExceptionSpecification() ? + (ExceptSpec.hasAnyExceptionSpecification() ? EST_DynamicAny : EST_Dynamic) : + EST_None; EPI.NumExceptions = ExceptSpec.size(); EPI.Exceptions = ExceptSpec.data(); - + // Create the actual constructor declaration. CanQualType ClassType = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl)); @@ -4989,8 +4990,9 @@ CXXDestructorDecl *Sema::DeclareImplicitDestructor(CXXRecordDecl *ClassDecl) { // Create the actual destructor declaration. FunctionProtoType::ExtProtoInfo EPI; - EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification(); - EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification(); + EPI.ExceptionSpecType = ExceptSpec.hasExceptionSpecification() ? + (ExceptSpec.hasAnyExceptionSpecification() ? EST_DynamicAny : EST_Dynamic) : + EST_None; EPI.NumExceptions = ExceptSpec.size(); EPI.Exceptions = ExceptSpec.data(); QualType Ty = Context.getFunctionType(Context.VoidTy, 0, 0, EPI); @@ -5387,8 +5389,9 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) { // An implicitly-declared copy assignment operator is an inline public // member of its class. FunctionProtoType::ExtProtoInfo EPI; - EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification(); - EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification(); + EPI.ExceptionSpecType = ExceptSpec.hasExceptionSpecification() ? + (ExceptSpec.hasAnyExceptionSpecification() ? EST_DynamicAny : EST_Dynamic) : + EST_None; EPI.NumExceptions = ExceptSpec.size(); EPI.Exceptions = ExceptSpec.data(); DeclarationName Name = Context.DeclarationNames.getCXXOperatorName(OO_Equal); @@ -5849,8 +5852,9 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor( // An implicitly-declared copy constructor is an inline public // member of its class. FunctionProtoType::ExtProtoInfo EPI; - EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification(); - EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification(); + EPI.ExceptionSpecType = ExceptSpec.hasExceptionSpecification() ? + (ExceptSpec.hasAnyExceptionSpecification() ? EST_DynamicAny : EST_Dynamic) : + EST_None; EPI.NumExceptions = ExceptSpec.size(); EPI.Exceptions = ExceptSpec.data(); DeclarationName Name diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 123e185cab..75ae8c215a 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -129,8 +129,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { Context.getSourceManager().isInSystemHeader(Old->getLocation())) && Old->isExternC()) { FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo(); - EPI.HasExceptionSpec = true; - EPI.HasAnyExceptionSpec = false; + EPI.ExceptionSpecType = EST_Dynamic; EPI.NumExceptions = 0; QualType NewType = Context.getFunctionType(NewProto->getResultType(), NewProto->arg_type_begin(), @@ -145,8 +144,9 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { = Old->getType()->getAs<FunctionProtoType>(); FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo(); - EPI.HasExceptionSpec = OldProto->hasExceptionSpec(); - EPI.HasAnyExceptionSpec = OldProto->hasAnyExceptionSpec(); + EPI.ExceptionSpecType = OldProto->hasExceptionSpec() ? + (OldProto->hasAnyExceptionSpec() ? EST_DynamicAny : EST_Dynamic) : + EST_None; EPI.NumExceptions = OldProto->getNumExceptions(); EPI.Exceptions = OldProto->exception_begin(); diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index eee02096ac..e4ac3ed6bb 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1501,7 +1501,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, } FunctionProtoType::ExtProtoInfo EPI; - EPI.HasExceptionSpec = true; + EPI.ExceptionSpecType = EST_Dynamic; if (HasBadAllocExceptionSpec) { EPI.NumExceptions = 1; EPI.Exceptions = &BadAllocType; diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index d1b6ef104d..3315ab6e53 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -686,8 +686,7 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { // FIXME: Calling convention! FunctionProtoType::ExtProtoInfo EPI = ConvProto->getExtProtoInfo(); EPI.ExtInfo = EPI.ExtInfo.withCallingConv(CC_Default); - EPI.HasExceptionSpec = false; - EPI.HasAnyExceptionSpec = false; + EPI.ExceptionSpecType = EST_None; EPI.NumExceptions = 0; QualType ExpectedType = R.getSema().Context.getFunctionType(R.getLookupName().getCXXNameType(), diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 3473c87709..b668e17386 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2158,8 +2158,9 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, // Rebuild the function type FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo(); - EPI.HasExceptionSpec = Proto->hasExceptionSpec(); - EPI.HasAnyExceptionSpec = Proto->hasAnyExceptionSpec(); + EPI.ExceptionSpecType = Proto->hasExceptionSpec() ? + (Proto->hasAnyExceptionSpec() ? EST_DynamicAny : EST_Dynamic) : + EST_None; EPI.NumExceptions = Exceptions.size(); EPI.Exceptions = Exceptions.data(); EPI.ExtInfo = Proto->getExtInfo(); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 33df7a0529..efb44df474 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1855,11 +1855,8 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, } llvm::SmallVector<QualType, 4> Exceptions; - if (FTI.getExceptionSpecType() == EST_Dynamic || - FTI.getExceptionSpecType() == EST_DynamicAny) { - EPI.HasExceptionSpec = true; - EPI.HasAnyExceptionSpec = - FTI.getExceptionSpecType() == EST_DynamicAny; + EPI.ExceptionSpecType = FTI.getExceptionSpecType(); + if (FTI.getExceptionSpecType() == EST_Dynamic) { Exceptions.reserve(FTI.NumExceptions); for (unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) { // FIXME: Preserve type source info. @@ -1871,6 +1868,8 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, } EPI.NumExceptions = Exceptions.size(); EPI.Exceptions = Exceptions.data(); + } else if (FTI.getExceptionSpecType() == EST_ComputedNoexcept) { + EPI.NoexceptExpr = FTI.NoexceptExpr; } T = Context.getFunctionType(T, ArgTys.data(), ArgTys.size(), EPI); diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 83b1239b7f..72637c1eb0 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3111,8 +3111,10 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) { EPI.Variadic = Record[Idx++]; EPI.TypeQuals = Record[Idx++]; EPI.RefQualifier = static_cast<RefQualifierKind>(Record[Idx++]); - EPI.HasExceptionSpec = Record[Idx++]; - EPI.HasAnyExceptionSpec = Record[Idx++]; + bool HasExceptionSpec = Record[Idx++]; + bool HasAnyExceptionSpec = Record[Idx++]; + EPI.ExceptionSpecType = HasExceptionSpec ? + (HasAnyExceptionSpec ? EST_DynamicAny : EST_Dynamic) : EST_None; EPI.NumExceptions = Record[Idx++]; llvm::SmallVector<QualType, 2> Exceptions; for (unsigned I = 0; I != EPI.NumExceptions; ++I) |