diff options
author | Steve Naroff <snaroff@apple.com> | 2007-08-08 17:48:34 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-08-08 17:48:34 +0000 |
commit | 4bc57c0de7f5db34ea9279322e277e7a4da9b27b (patch) | |
tree | 92faa15474fb7e6f98f5fe7979d9becf7a698187 | |
parent | 5ebb2fed89a1f0852537ff86265841c0f6b6971d (diff) | |
download | bcm5719-llvm-4bc57c0de7f5db34ea9279322e277e7a4da9b27b.tar.gz bcm5719-llvm-4bc57c0de7f5db34ea9279322e277e7a4da9b27b.zip |
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...
llvm-svn: 40930
-rw-r--r-- | clang/AST/Builtins.cpp | 16 | ||||
-rw-r--r-- | clang/include/clang/AST/Builtins.def | 1 |
2 files changed, 14 insertions, 3 deletions
diff --git a/clang/AST/Builtins.cpp b/clang/AST/Builtins.cpp index 454085bf2a5..099b1138d02 100644 --- a/clang/AST/Builtins.cpp +++ b/clang/AST/Builtins.cpp @@ -88,7 +88,7 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context) { 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 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context) { 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 @@ QualType Builtin::Context::GetBuiltinType(unsigned id, ASTContext &Context)const 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] == '.'); } diff --git a/clang/include/clang/AST/Builtins.def b/clang/include/clang/AST/Builtins.def index 97431da9512..2a5a8c76a86 100644 --- a/clang/include/clang/AST/Builtins.def +++ b/clang/include/clang/AST/Builtins.def @@ -49,5 +49,6 @@ BUILTIN(__builtin_fabs , "dd" , "nc") BUILTIN(__builtin_fabsf, "ff" , "nc") BUILTIN(__builtin_fabsl, "LdLd", "nc") BUILTIN(__builtin_constant_p, "UsUs", "nc") +BUILTIN(__builtin_classify_type, "i.", "nc") #undef BUILTIN |