[cfe-commits] r121770 - in /cfe/trunk: include/clang/AST/Type.h lib/Sema/SemaType.cpp

John McCall rjmccall at apple.com
Tue Dec 14 08:45:57 PST 2010


Author: rjmccall
Date: Tue Dec 14 10:45:57 2010
New Revision: 121770

URL: http://llvm.org/viewvc/llvm-project?rev=121770&view=rev
Log:
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.


Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=121770&r1=121769&r2=121770&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Dec 14 10:45:57 2010
@@ -2125,9 +2125,13 @@
   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 @@
   // * 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<unsigned char>(Bits)) {}
 
     friend class FunctionType;
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=121770&r1=121769&r2=121770&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Dec 14 10:45:57 2010
@@ -1327,7 +1327,6 @@
         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 @@
             if (!CheckSpecifiedExceptionType(ET, FTI.Exceptions[ei].Range))
               Exceptions.push_back(ET);
           }
+          EPI.NumExceptions = Exceptions.size();
           EPI.Exceptions = Exceptions.data();
         }
 





More information about the cfe-commits mailing list