[cfe-dev] [RFC] Introduce overflow builtins
Eli Friedman
eli.friedman at gmail.com
Tue May 8 19:37:05 PDT 2012
On Sat, Apr 21, 2012 at 8:21 AM, Tobias Grosser <tobias at grosser.es> wrote:
> On 04/04/2012 10:48 PM, Chris Lattner wrote:
>>
>>
>> On Apr 2, 2012, at 11:57 AM, Xi Wang wrote:
>>
>>> On Apr 2, 2012, at 1:04 PM, Dave Zarzycki wrote:
>>>
>>>> A colleague pointed out that i8 works. See the example at the end of
>>>> this email and please consider adding support for 8-bit integers for the
>>>> sake of completeness. Thanks! :-)
>>>
>>>
>>> Hah, thanks for letting me know this hidden feature. Probably
>>> http://llvm.org/docs/LangRef.html should get updated, too.
>>>
>>> Pushed out.
>>>
>>> https://github.com/xiw/clang/compare/master...builtin-overflow
>>
>>
>> This looks generally reasonable to me, but could use review by someone
>> else. Eli or John, could you take a look?
>
>
> I am very interested in this. The patch is very simple and looks at a first
> glance clean.
>
> Eli or John: I attached it to simplify review. Mind having a look?
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