[cfe-dev] [RFC] Introduce overflow builtins

Dave Zarzycki zarzycki at apple.com
Fri Mar 30 13:32:07 PDT 2012


Xi,

Thanks for the update! Have you tried inferring the sign of T* in addition to the size of T* in the API? That would let you simplify this:

	__builtin_sadd_with_overflow()
	__builtin_uadd_with_overflow()
	__builtin_ssub_with_overflow()
	__builtin_usub_with_overflow()
	__builtin_smul_with_overflow()
	__builtin_umul_with_overflow()

To this:

	__builtin_add_with_overflow()
	__builtin_sub_with_overflow()
	__builtin_mul_with_overflow()

Also, have you verified that -Wconversion does the right thing and warns when the sign of the parameters are inconsistent with each other (or the API if you do not make the above simplification)?

davez



On Mar 30, 2012, at 12:24 PM, Xi Wang <xi.wang at gmail.com> wrote:

> Hi,
> 
> I updated the overflow builtins to the form
> 
>    __builtin_*_with_overflow(T*, T, T)
> 
> as suggested by Chris and Dave.
> 
> The patch is still available at
> 
> https://github.com/xiw/clang/compare/master...builtin-overflow
> 
> - xi
> 




More information about the cfe-dev mailing list