[cfe-dev] Way to disable sanitize checks locally

Will Dietz willdtz at gmail.com
Thu Dec 13 11:57:59 PST 2012


On Thu, Dec 13, 2012 at 1:55 PM, Will Dietz <willdtz at gmail.com> wrote:
> On Thu, Dec 13, 2012 at 12:27 PM, Sean McBride <sean at rogue-research.com> wrote:
>> On Thu, 13 Dec 2012 10:06:49 -0800, zapadinsky said:
>>
>>>Hi I am new here. I am using clang to check errors in our code. Specifically
>>>integer overflows. But sometimes it is ok, some dirty code are ok, for
>>>example in hash function calculation. How can I disable sanitize checks
>>>locally for one inlined function for example?
>>
>
> Glad to hear it!
>
> Adding attributes to annotate safe locations is on my TODO list, as
> this is an important feature for usability.  It shouldn't take too
> long, but even so unfortunately I don't think I'll be able to get to
> it for at least a few days.
>
> Apologies for any inconvenience!
>
> ~Will
>
>> Are your hash function calculations using unsigned integers or signed integers?  Overflowing the former is well-defined, the latter is not.  That's why -fsanitize=undefined does not include -fsanitize=unsigned-integer-overflow, see here:
>>
>> <http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation>
>>
>> Cheers,
>>
>> --
>> ____________________________________________________________
>> Sean McBride, B. Eng                 sean at rogue-research.com
>> Rogue Research                        www.rogue-research.com
>> Mac Software Developer              Montréal, Québec, Canada
>>
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

A temporary kludge might be to push the hash function into a separate
TU, build it without overflow checking (or just disable the overflow
checks that are intentional).

If LTO is an option for your project, you could use that to then
inline the function and restore your original functionality.

Hope this helps,

~Will




More information about the cfe-dev mailing list