From: John McCall Date: Tue, 14 Dec 2010 16:45:57 +0000 (+0000) Subject: Improve some comments, shrink FunctionType::ExtInfo, and fix a bug found X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=373920bd733b1d28fe7bf209945a62eb9248d948;p=clang Improve some comments, shrink FunctionType::ExtInfo, and fix a bug found by valgrind where we were doing the wrong thing in the presence of invalid exception specs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121770 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 686331f44c..229119c781 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -2125,9 +2125,13 @@ class FunctionType : public Type { QualType ResultType; public: - // This class is used for passing around the information needed to - // construct a call. It is not actually used for storage, just for - // factoring together common arguments. + /// ExtInfo - A class which abstracts out some details necessary for + /// making a call. + /// + /// It is not actually used directly for storing this information in + /// a FunctionType, although FunctionType does currently use the + /// same bit-pattern. + /// // If you add a field (say Foo), other than the obvious places (both, // constructors, compile failures), what you need to update is // * Operator== @@ -2141,16 +2145,21 @@ class FunctionType : public Type { // * TypePrinter::PrintFunctionProto // * AST read and write // * Codegen - class ExtInfo { + // Feel free to rearrange or add bits, but if you go over 8, + // you'll need to adjust both the Bits field below and + // Type::FunctionTypeBitfields. + + // | CC |noreturn|regparm + // |0 .. 2| 3 |4 .. 6 enum { CallConvMask = 0x7 }; enum { NoReturnMask = 0x8 }; enum { RegParmMask = ~(CallConvMask | NoReturnMask), RegParmOffset = 4 }; - unsigned Bits; + unsigned char Bits; - ExtInfo(unsigned Bits) : Bits(Bits) {} + ExtInfo(unsigned Bits) : Bits(static_cast(Bits)) {} friend class FunctionType; diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 2a75ff0b34..04440ef9a5 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1327,7 +1327,6 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, if (FTI.hasExceptionSpec) { EPI.HasExceptionSpec = FTI.hasExceptionSpec; EPI.HasAnyExceptionSpec = FTI.hasAnyExceptionSpec; - EPI.NumExceptions = FTI.NumExceptions; Exceptions.reserve(FTI.NumExceptions); for (unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) { // FIXME: Preserve type source info. @@ -1337,6 +1336,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, if (!CheckSpecifiedExceptionType(ET, FTI.Exceptions[ei].Range)) Exceptions.push_back(ET); } + EPI.NumExceptions = Exceptions.size(); EPI.Exceptions = Exceptions.data(); }