[cfe-dev] ObjC builtin functions for GNU back end

Eli Friedman eli.friedman at gmail.com
Mon Mar 30 10:49:50 PDT 2009


On Mon, Mar 30, 2009 at 10:37 AM, David Chisnall <csdavec at swansea.ac.uk> wrote:
> Something like:
>
> int __builtin_add_check_overflow(int*, int, int)

Do you mean __builtin_signed_add_check_overflow?  Or are we assuming
nobody cares about unsigned overflow?

> Would be be nice, with the return being a zero-extended version of the i1
> (or, since clang supports arbitrary-with integers now, leaving it as an i1,
> as long as this can be used in a comparison).

So rather, "_Bool __builtin_signed_add_check_overflow(int*, int,
int)"?  Seems reasonable, and rather easy to implement.

> if (__builtin_expect(__builtin_add_check_overflow(&a, b, c), 0))

Note that LLVM doesn't support __builtin_expect...

-Eli



More information about the cfe-dev mailing list