[cfe-commits] adding "-fasan" flag

Kostya Serebryany kcc at google.com
Tue Nov 15 21:02:25 PST 2011


On Tue, Nov 15, 2011 at 8:51 PM, Chandler Carruth <chandlerc at google.com>wrote:

> On Tue, Nov 15, 2011 at 8:46 PM, Kostya Serebryany <kcc at google.com> wrote:
>
>>
>>> See http://clang.llvm.org/docs/LanguageExtensions.html#feature_check --
>>> it should be completely compiler neutral.
>>>
>>
>> So, the user code will have to look like this?
>>
>> #ifndef __has_feature
>> # define __has_feature(x) 0
>> #endif
>> ...
>>
>>  #if __has_feature(address_sanitizer)
>> ..
>> #endif
>>
>
> I would hope it could be simplified as:
>
> #if defined(__has_feature) && __has_feature(address_sanitizer)
> ...
> #endif
>

What is the status of __has_feature?
Is it a pure clang extension?
Is it suggested for standardization?
If other compilers are not going to accept/implement __has_feature I afraid
that the user code will actually have to look like this:

#if defined(__has_feature) && __has_feature(address_sanitizer)
# define ADDRESS_SANITIZER 1
# elif defined(__gcc_analog_of_has_feature)
&& __gcc_analog_of_has_feature(address_sanitizer)
# define ADDRESS_SANITIZER 1
# elif defined(__msvc_analog_of_has_feature)
&& __msvc_analog_of_has_feature(address_sanitizer)
# define ADDRESS_SANITIZER 1
#endif

#ifdef ADDRESS_SANITIZER
<code>
#endif

Argument 'can be easily implemented in gcc' does not work.
We need something like 'will most likely be accepted by gcc' for any value
of 'gcc'.

--kcc


>
> But either way, yes in essence.
>
>
>> Also, is that indeed the right use of __has_feature? Maybe
>> __has_extension fits better?
>> Hm, asan is not an extension nor a (C++ standard) feature.
>>
>
> This is a good point. I wonder if there needs to be another __has_* macro
> John? (maybe Doug?) I don't know what to call it. It's a feature which is
> not related to the standard in any way.
>
> There are other things that I can conceive of wanting to put here:
> -fcatch-undefined-behavior, -ftrapv, etc...
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111115/19978507/attachment.html>


More information about the cfe-commits mailing list