From 4d3cbf0335dc43a281377052afa180af28f39e7f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 7 May 2009 04:47:06 +0000 Subject: [PATCH] Add support for LLLi -> int128 in builtins.def git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71148 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Builtins.cpp | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index 3e1b3dc2a1..ca75c5d51a 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -100,7 +100,8 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context, Builtin::Context::GetBuiltinTypeError &Error, bool AllowTypeModifiers = true) { // Modifiers. - bool Long = false, LongLong = false, Signed = false, Unsigned = false; + int HowLong = 0; + bool Signed = false, Unsigned = false; // Read the modifiers first. bool Done = false; @@ -118,11 +119,8 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context, Unsigned = true; break; case 'L': - assert(!LongLong && "Can't have LLL modifier"); - if (Long) - LongLong = true; - else - Long = true; + assert(HowLong <= 2 && "Can't have LLLL modifier"); + ++HowLong; break; } } @@ -133,39 +131,42 @@ 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 'v'!"); + assert(HowLong == 0 && !Signed && !Unsigned && + "Bad modifiers used with 'v'!"); Type = Context.VoidTy; break; case 'f': - assert(!Long && !Signed && !Unsigned && "Bad modifiers used with 'f'!"); + assert(HowLong == 0 && !Signed && !Unsigned && + "Bad modifiers used with 'f'!"); Type = Context.FloatTy; break; case 'd': - assert(!LongLong && !Signed && !Unsigned && "Bad modifiers used with 'd'!"); - if (Long) + assert(HowLong < 2 && !Signed && !Unsigned && + "Bad modifiers used with 'd'!"); + if (HowLong) Type = Context.LongDoubleTy; else Type = Context.DoubleTy; break; case 's': - assert(!LongLong && "Bad modifiers used with 's'!"); + assert(HowLong == 0 && "Bad modifiers used with 's'!"); if (Unsigned) Type = Context.UnsignedShortTy; else Type = Context.ShortTy; - break; + break; case 'i': - if (LongLong) + if (HowLong == 3) + Type = Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty; + else if (HowLong == 2) Type = Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy; - else if (Long) + else if (HowLong == 1) Type = Unsigned ? Context.UnsignedLongTy : Context.LongTy; - else if (Unsigned) - Type = Context.UnsignedIntTy; - else - Type = Context.IntTy; // default is signed. + else + Type = Unsigned ? Context.UnsignedIntTy : Context.IntTy; break; case 'c': - assert(!Long && !LongLong && "Bad modifiers used with 'c'!"); + assert(HowLong == 0 && "Bad modifiers used with 'c'!"); if (Signed) Type = Context.SignedCharTy; else if (Unsigned) @@ -174,11 +175,11 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context, Type = Context.CharTy; break; case 'b': // boolean - assert(!Long && !Signed && !Unsigned && "Bad modifiers for 'b'!"); + assert(HowLong == 0 && !Signed && !Unsigned && "Bad modifiers for 'b'!"); Type = Context.BoolTy; break; case 'z': // size_t. - assert(!Long && !Signed && !Unsigned && "Bad modifiers for 'z'!"); + assert(HowLong == 0 && !Signed && !Unsigned && "Bad modifiers for 'z'!"); Type = Context.getSizeType(); break; case 'F': -- 2.40.0