[cfe-commits] r40930 - in /cfe/trunk: AST/Builtins.cpp include/clang/AST/Builtins.def

Steve Naroff snaroff at apple.com
Wed Aug 8 10:48:34 PDT 2007


Author: snaroff
Date: Wed Aug  8 12:48:34 2007
New Revision: 40930

URL: http://llvm.org/viewvc/llvm-project?rev=40930&view=rev
Log:
Add support for __builtin_classify_type(). This builtin function isn't "public", however
it is used by "tgmath.h" (so we need to support it). It might also come in handy when
developing the overloaded function macros for OpenCU.

Next check-in will make this an integer constant expression...

Modified:
    cfe/trunk/AST/Builtins.cpp
    cfe/trunk/include/clang/AST/Builtins.def

Modified: cfe/trunk/AST/Builtins.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Builtins.cpp?rev=40930&r1=40929&r2=40930&view=diff

==============================================================================
--- cfe/trunk/AST/Builtins.cpp (original)
+++ cfe/trunk/AST/Builtins.cpp Wed Aug  8 12:48:34 2007
@@ -88,7 +88,7 @@
   switch (*Str++) {
   default: assert(0 && "Unknown builtin type letter!");
   case 'v':
-    assert(!Long && !Signed && !Unsigned && "Bad modifiers used with 'f'!");
+    assert(!Long && !Signed && !Unsigned && "Bad modifiers used with 'v'!");
     return Context.VoidTy;
   case 'f':
     assert(!Long && !Signed && !Unsigned && "Bad modifiers used with 'f'!");
@@ -103,7 +103,14 @@
     if (Unsigned)
       return Context.UnsignedShortTy;
     return Context.ShortTy;
-  //case 'i':
+  case 'i':
+    if (Long)
+      return Unsigned ? Context.UnsignedLongTy : Context.LongTy;
+    if (LongLong)
+      return Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
+    if (Unsigned)
+      return Context.UnsignedIntTy;
+    return Context.IntTy; // default is signed.
   }
 }
 
@@ -119,7 +126,10 @@
   
   assert((TypeStr[0] != '.' || TypeStr[1] == 0) &&
          "'.' should only occur at end of builtin type list!");
-  
+
+  // handle untyped/variadic arguments "T c99Style();" or "T cppStyle(...);".
+  if (ArgTypes.size() == 0 && TypeStr[0] == '.')
+    return Context.getFunctionTypeNoProto(ResType);
   return Context.getFunctionType(ResType, &ArgTypes[0], ArgTypes.size(),
                                  TypeStr[0] == '.');
 }

Modified: cfe/trunk/include/clang/AST/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Builtins.def?rev=40930&r1=40929&r2=40930&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Builtins.def (original)
+++ cfe/trunk/include/clang/AST/Builtins.def Wed Aug  8 12:48:34 2007
@@ -49,5 +49,6 @@
 BUILTIN(__builtin_fabsf, "ff"  , "nc")
 BUILTIN(__builtin_fabsl, "LdLd", "nc")
 BUILTIN(__builtin_constant_p, "UsUs", "nc")
+BUILTIN(__builtin_classify_type, "i.", "nc")
 
 #undef BUILTIN





More information about the cfe-commits mailing list