[cfe-dev] [RFC] Introduce overflow builtins

Xi Wang xi.wang at gmail.com
Thu May 24 20:52:10 PDT 2012


Sorry for the late response.  Just got back from a trip.

Thanks very much for the comments.  The updated patch is attached.

- whitespace nit
- remove useless check
- reject bool type

You can also review the changes at

https://github.com/xiw/clang/compare/builtin-overflow

- xi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: overflow.patch
Type: application/octet-stream
Size: 11362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120524/45bab869/attachment.obj>
-------------- next part --------------

On May 8, 2012, at 10:37 PM, Eli Friedman wrote:
> 
> Sorry about the long delay... I've been busy with other things, and
> this slipped off my queue.
> 
> +  switch (Context.getTypeSizeInChars(ValTy).getQuantity()) {
> +  case 1:
> +  case 2:
> +  case 4:
> +  case 8:
> +  case 16:
> +    break;
> +  default:
> +    return Diag(DRE->getLocStart(), diag::err_overflow_builtin_pointer_size)
> +      << Ptr->getType() << Ptr->getSourceRange();
> +  }
> 
> I'm not sure what you're trying to catch with this check... it will
> pass for every integer type we currently support.
> 
> Related: we probably want to reject __builtin_add_with_overflow(bool*,
> bool, bool).
> 
> +    Intrinsic::ID ID = T->hasSignedIntegerRepresentation()? SID: UID;
> 
> Minor nit: whitespace.
> 
> Otherwise, this looks good.  Again, sorry about the delay.
> 
> -Eli



More information about the cfe-dev mailing list