[cfe-commits] r127118 - in /cfe/trunk: include/clang/AST/Type.h include/clang/Basic/ExceptionSpecificationType.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

Sebastian Redl sebastian.redl at getdesigned.at
Sun Mar 6 02:52:05 PST 2011


Author: cornedbee
Date: Sun Mar  6 04:52:04 2011
New Revision: 127118

URL: http://llvm.org/viewvc/llvm-project?rev=127118&view=rev
Log:
Reinstate r127112, "Propagate new-style exception spec information to ExtProtoInfo.", this time with the missing header.

Added:
    cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h
Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/include/clang/Sema/DeclSpec.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sun Mar  6 04:52:04 2011
@@ -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 @@
   /// 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 @@
     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;

Added: cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h?rev=127118&view=auto
==============================================================================
--- cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h (added)
+++ cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h Sun Mar  6 04:52:04 2011
@@ -0,0 +1,38 @@
+//===--- ExceptionSpecificationType.h ---------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the ExceptionSpecificationType enumeration and various
+// utility functions.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H
+#define LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H
+
+namespace clang {
+
+/// \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)
+};
+
+inline bool isDynamicExceptionSpec(ExceptionSpecificationType ESpecType) {
+  return ESpecType == EST_Dynamic || ESpecType == EST_DynamicAny;
+}
+
+inline bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType) {
+  return ESpecType == EST_BasicNoexcept || ESpecType == EST_ComputedNoexcept;
+}
+
+} // end namespace clang
+
+#endif // LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Sun Mar  6 04:52:04 2011
@@ -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 @@
 /// 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.
 ///

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Mar  6 04:52:04 2011
@@ -1913,7 +1913,7 @@
     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 @@
       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));
 

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sun Mar  6 04:52:04 2011
@@ -1173,8 +1173,8 @@
                  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 @@
   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());
   }

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Mar  6 04:52:04 2011
@@ -4712,11 +4712,12 @@
   }
 
   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 @@
   
   // 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 @@
   //   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 @@
   //   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

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Sun Mar  6 04:52:04 2011
@@ -129,8 +129,7 @@
        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 @@
       = 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();
 

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Mar  6 04:52:04 2011
@@ -1501,7 +1501,7 @@
   }
 
   FunctionProtoType::ExtProtoInfo EPI;
-  EPI.HasExceptionSpec = true;
+  EPI.ExceptionSpecType = EST_Dynamic;
   if (HasBadAllocExceptionSpec) {
     EPI.NumExceptions = 1;
     EPI.Exceptions = &BadAllocType;

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Sun Mar  6 04:52:04 2011
@@ -686,8 +686,7 @@
     // 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(),

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Sun Mar  6 04:52:04 2011
@@ -2158,8 +2158,9 @@
     // 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();

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sun Mar  6 04:52:04 2011
@@ -1855,11 +1855,8 @@
         }
 
         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 @@
           }
           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);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=127118&r1=127117&r2=127118&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Sun Mar  6 04:52:04 2011
@@ -3111,8 +3111,10 @@
     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)





More information about the cfe-commits mailing list