]> granicus.if.org Git - clang/commitdiff
Revert r127112, "Propagate new-style exception spec information to ExtProtoInfo."
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 6 Mar 2011 00:17:36 +0000 (00:17 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 6 Mar 2011 00:17:36 +0000 (00:17 +0000)
It seems missing "clang/Basic/ExceptionSpecificationType.h".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127115 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
include/clang/Sema/DeclSpec.h
lib/AST/ASTContext.cpp
lib/AST/Type.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExceptionSpec.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaLookup.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
lib/Sema/SemaType.cpp
lib/Serialization/ASTReader.cpp

index c194e7baa964238eb48af8391f447f6bc5efcc62..9b177cceed965d9c9387ff1385b67dacf22ba535 100644 (file)
@@ -15,7 +15,6 @@
 #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"
@@ -2404,17 +2403,17 @@ public:
   /// ExtProtoInfo - Extra information about a function prototype.
   struct ExtProtoInfo {
     ExtProtoInfo() :
-      Variadic(false), ExceptionSpecType(EST_None), TypeQuals(0),
-      RefQualifier(RQ_None), NumExceptions(0), Exceptions(0), NoexceptExpr(0) {}
+      Variadic(false), HasExceptionSpec(false), HasAnyExceptionSpec(false),
+      TypeQuals(0), RefQualifier(RQ_None), NumExceptions(0), Exceptions(0) {}
 
     FunctionType::ExtInfo ExtInfo;
     bool Variadic;
-    ExceptionSpecificationType ExceptionSpecType;
+    bool HasExceptionSpec;
+    bool HasAnyExceptionSpec;
     unsigned char TypeQuals;
     RefQualifierKind RefQualifier;
     unsigned NumExceptions;
     const QualType *Exceptions;
-    Expr *NoexceptExpr;
   };
 
 private:
@@ -2463,8 +2462,8 @@ public:
     ExtProtoInfo EPI;
     EPI.ExtInfo = getExtInfo();
     EPI.Variadic = isVariadic();
-    EPI.ExceptionSpecType = hasExceptionSpec() ?
-        (hasAnyExceptionSpec() ? EST_DynamicAny : EST_Dynamic) : EST_None;
+    EPI.HasExceptionSpec = hasExceptionSpec();
+    EPI.HasAnyExceptionSpec = hasAnyExceptionSpec();
     EPI.TypeQuals = static_cast<unsigned char>(getTypeQuals());
     EPI.RefQualifier = getRefQualifier();
     EPI.NumExceptions = NumExceptions;
index b7a64995021e3d289844add293072099a714d656..164dac096d15e95877b38a12e268d5586b553420 100644 (file)
@@ -24,7 +24,6 @@
 #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"
@@ -908,6 +907,15 @@ 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.
 ///
index f9cc06987b6e019f1f5ecb8afd6abb4ba83a75b9..3fd58ce9fdf0f763a09b89ab0f4eba448dd9a516 100644 (file)
@@ -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.ExceptionSpecType == EST_None && ResultTy.isCanonical();
+  bool isCanonical = !EPI.HasExceptionSpec && ResultTy.isCanonical();
   for (unsigned i = 0; i != NumArgs && isCanonical; ++i)
     if (!ArgArray[i].isCanonicalAsParam())
       isCanonical = false;
@@ -1932,8 +1932,11 @@ ASTContext::getFunctionType(QualType ResultTy,
       CanonicalArgs.push_back(getCanonicalParamType(ArgArray[i]));
 
     FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
-    CanonicalEPI.ExceptionSpecType = EST_None;
-    CanonicalEPI.NumExceptions = 0;
+    if (CanonicalEPI.HasExceptionSpec) {
+      CanonicalEPI.HasExceptionSpec = false;
+      CanonicalEPI.HasAnyExceptionSpec = false;
+      CanonicalEPI.NumExceptions = 0;
+    }
     CanonicalEPI.ExtInfo
       = CanonicalEPI.ExtInfo.withCallingConv(getCanonicalCallConv(CallConv));
 
index eea08f6242f2b06ff625fdc1f55b24601d68b391..cde865f5b9f18e4e3b5d16df0cca2dd049ada950 100644 (file)
@@ -1173,8 +1173,8 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args,
                  result->containsUnexpandedParameterPack(),
                  epi.ExtInfo),
     NumArgs(numArgs), NumExceptions(epi.NumExceptions),
-    HasExceptionSpec(isDynamicExceptionSpec(epi.ExceptionSpecType)),
-    HasAnyExceptionSpec(epi.ExceptionSpecType == EST_DynamicAny)
+    HasExceptionSpec(epi.HasExceptionSpec),
+    HasAnyExceptionSpec(epi.HasAnyExceptionSpec)
 {
   // 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 (isDynamicExceptionSpec(epi.ExceptionSpecType)) {
-    ID.AddBoolean(epi.ExceptionSpecType == EST_DynamicAny);
+  if (epi.HasExceptionSpec) {
+    ID.AddBoolean(epi.HasAnyExceptionSpec);
     for (unsigned i = 0; i != epi.NumExceptions; ++i)
       ID.AddPointer(epi.Exceptions[i].getAsOpaquePtr());
   }
index ba929587aeaf3ff875998fe617232d5cfb754283..623e72f29980027080887129e41de66eddafbf99 100644 (file)
@@ -4712,12 +4712,11 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor(
   }
 
   FunctionProtoType::ExtProtoInfo EPI;
-  EPI.ExceptionSpecType = ExceptSpec.hasExceptionSpecification() ?
-    (ExceptSpec.hasAnyExceptionSpecification() ? EST_DynamicAny : EST_Dynamic) :
-    EST_None;
+  EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification();
+  EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification();
   EPI.NumExceptions = ExceptSpec.size();
   EPI.Exceptions = ExceptSpec.data();
-
+  
   // Create the actual constructor declaration.
   CanQualType ClassType
     = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
@@ -4990,9 +4989,8 @@ CXXDestructorDecl *Sema::DeclareImplicitDestructor(CXXRecordDecl *ClassDecl) {
   
   // Create the actual destructor declaration.
   FunctionProtoType::ExtProtoInfo EPI;
-  EPI.ExceptionSpecType = ExceptSpec.hasExceptionSpecification() ?
-    (ExceptSpec.hasAnyExceptionSpecification() ? EST_DynamicAny : EST_Dynamic) :
-    EST_None;
+  EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification();
+  EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification();
   EPI.NumExceptions = ExceptSpec.size();
   EPI.Exceptions = ExceptSpec.data();
   QualType Ty = Context.getFunctionType(Context.VoidTy, 0, 0, EPI);
@@ -5389,9 +5387,8 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) {
   //   An implicitly-declared copy assignment operator is an inline public
   //   member of its class.
   FunctionProtoType::ExtProtoInfo EPI;
-  EPI.ExceptionSpecType = ExceptSpec.hasExceptionSpecification() ?
-    (ExceptSpec.hasAnyExceptionSpecification() ? EST_DynamicAny : EST_Dynamic) :
-    EST_None;
+  EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification();
+  EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification();
   EPI.NumExceptions = ExceptSpec.size();
   EPI.Exceptions = ExceptSpec.data();
   DeclarationName Name = Context.DeclarationNames.getCXXOperatorName(OO_Equal);
@@ -5852,9 +5849,8 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor(
   //   An implicitly-declared copy constructor is an inline public
   //   member of its class.
   FunctionProtoType::ExtProtoInfo EPI;
-  EPI.ExceptionSpecType = ExceptSpec.hasExceptionSpecification() ?
-    (ExceptSpec.hasAnyExceptionSpecification() ? EST_DynamicAny : EST_Dynamic) :
-    EST_None;
+  EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification();
+  EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification();
   EPI.NumExceptions = ExceptSpec.size();
   EPI.Exceptions = ExceptSpec.data();
   DeclarationName Name
index 75ae8c215ab0652ceeb2f718b1ba9e1b831898d5..123e185cab3d52be43517fd19b281b3bdd25ca62 100644 (file)
@@ -129,7 +129,8 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
        Context.getSourceManager().isInSystemHeader(Old->getLocation())) &&
       Old->isExternC()) {
     FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo();
-    EPI.ExceptionSpecType = EST_Dynamic;
+    EPI.HasExceptionSpec = true;
+    EPI.HasAnyExceptionSpec = false;
     EPI.NumExceptions = 0;
     QualType NewType = Context.getFunctionType(NewProto->getResultType(),
                                                NewProto->arg_type_begin(),
@@ -144,9 +145,8 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
       = Old->getType()->getAs<FunctionProtoType>();
 
     FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo();
-    EPI.ExceptionSpecType = OldProto->hasExceptionSpec() ?
-      (OldProto->hasAnyExceptionSpec() ? EST_DynamicAny : EST_Dynamic) :
-      EST_None;
+    EPI.HasExceptionSpec = OldProto->hasExceptionSpec();
+    EPI.HasAnyExceptionSpec = OldProto->hasAnyExceptionSpec();
     EPI.NumExceptions = OldProto->getNumExceptions();
     EPI.Exceptions = OldProto->exception_begin();
 
index e4ac3ed6bbbb4be688e749dceb725962866dcc8f..eee02096ac794cb67b9a429fdf49337641402070 100644 (file)
@@ -1501,7 +1501,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
   }
 
   FunctionProtoType::ExtProtoInfo EPI;
-  EPI.ExceptionSpecType = EST_Dynamic;
+  EPI.HasExceptionSpec = true;
   if (HasBadAllocExceptionSpec) {
     EPI.NumExceptions = 1;
     EPI.Exceptions = &BadAllocType;
index 3315ab6e53ada5352d238016143a0655aff1d7d4..d1b6ef104d3a6a06f2869a819b63f439475ad830 100644 (file)
@@ -686,7 +686,8 @@ 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.ExceptionSpecType = EST_None;
+    EPI.HasExceptionSpec = false;
+    EPI.HasAnyExceptionSpec = false;
     EPI.NumExceptions = 0;
     QualType ExpectedType
       = R.getSema().Context.getFunctionType(R.getLookupName().getCXXNameType(),
index b668e173867639e087337f57f47169b6fd049105..3473c877093c1b2b54eb5568f75fb994bb631009 100644 (file)
@@ -2158,9 +2158,8 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
     // Rebuild the function type 
 
     FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo();
-    EPI.ExceptionSpecType = Proto->hasExceptionSpec() ?
-      (Proto->hasAnyExceptionSpec() ? EST_DynamicAny : EST_Dynamic) :
-      EST_None;
+    EPI.HasExceptionSpec = Proto->hasExceptionSpec();
+    EPI.HasAnyExceptionSpec = Proto->hasAnyExceptionSpec();
     EPI.NumExceptions = Exceptions.size();
     EPI.Exceptions = Exceptions.data();
     EPI.ExtInfo = Proto->getExtInfo();
index efb44df4746b7064e2c8076b5e2c1bb5f6279a23..33df7a0529f2d48b46f844b51dcb54833aa56093 100644 (file)
@@ -1855,8 +1855,11 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
         }
 
         llvm::SmallVector<QualType, 4> Exceptions;
-        EPI.ExceptionSpecType = FTI.getExceptionSpecType();
-        if (FTI.getExceptionSpecType() == EST_Dynamic) {
+        if (FTI.getExceptionSpecType() == EST_Dynamic ||
+            FTI.getExceptionSpecType() == EST_DynamicAny) {
+          EPI.HasExceptionSpec = true;
+          EPI.HasAnyExceptionSpec =
+              FTI.getExceptionSpecType() == EST_DynamicAny;
           Exceptions.reserve(FTI.NumExceptions);
           for (unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) {
             // FIXME: Preserve type source info.
@@ -1868,8 +1871,6 @@ 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);
index 72637c1eb0b6502a132c59fa92f55fe34046c3c3..83b1239b7f31c81b20b81acbb48fb3ea1451034e 100644 (file)
@@ -3111,10 +3111,8 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) {
     EPI.Variadic = Record[Idx++];
     EPI.TypeQuals = Record[Idx++];
     EPI.RefQualifier = static_cast<RefQualifierKind>(Record[Idx++]);
-    bool HasExceptionSpec = Record[Idx++];
-    bool HasAnyExceptionSpec = Record[Idx++];
-    EPI.ExceptionSpecType = HasExceptionSpec ?
-        (HasAnyExceptionSpec ? EST_DynamicAny : EST_Dynamic) : EST_None;
+    EPI.HasExceptionSpec = Record[Idx++];
+    EPI.HasAnyExceptionSpec = Record[Idx++];
     EPI.NumExceptions = Record[Idx++];
     llvm::SmallVector<QualType, 2> Exceptions;
     for (unsigned I = 0; I != EPI.NumExceptions; ++I)