[cfe-commits] [PATCH] Improved handling of 128-bit integer literals

Stephen Canon scanon at apple.com
Fri Nov 30 11:29:54 PST 2012


On Nov 30, 2012, at 2:01 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> On Fri, Nov 30, 2012 at 1:50 PM, Stephen Canon <scanon at apple.com> wrote:
>> • fixed indentation
>> • i32 and i64 will now have the correct size (instead of i32 being "long" even on LP64 platforms).  We can't do this for i8 or i16 without more invasive changes, so those will wait for another patch.
>> • MS literals get sign- or zero-extended as appropriate.
>> • MS literal path is generally cleaner.
>> • adopted hasInt128Type().
> 
> +  if (sizeof(__uint64_t) <= sizeof(int)) {
> +    ASSERT_TRUE(PrintedStmtMSMatches(
> +    "void A() { 1i64, -1i64, 1ui64; }",
> +    "A", "1 , -1 , 1U"));
> +  } else if (sizeof(__uint64_t) <= sizeof(long)) {
> +    ASSERT_TRUE(PrintedStmtMSMatches(
> +    "void A() { 1i64, -1i64, 1ui64; }",
> +    "A", "1L , -1L , 1UL"));
> +  } else {
> +    ASSERT_TRUE(PrintedStmtMSMatches(
> +    "void A() { 1i64, -1i64, 1ui64; }",
> +    "A", "1LL , -1LL , 1ULL"));
> +  }
> 
> This does not look portable.  Why can't we fold sizeof(__uint64_t) to
> 8?  And also, this assumes that clang will target the same platform as
> host...

Suggestions on how to fix this welcome; it's unquestionably more correct than the test that was previously here (which simply assumed that long = 32b, long long = 64b).

- Steve



More information about the cfe-commits mailing list