<div class="gmail_quote">On Tue, Nov 15, 2011 at 8:25 PM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com">kcc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div><div class="h5">On Tue, Nov 15, 2011 at 7:10 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div><div><div></div></div></div><div>On Nov 15, 2011, at 6:40 PM, Eli Friedman wrote:<br>
> On Tue, Nov 15, 2011 at 6:22 PM, Kostya Serebryany <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>> wrote:<br>
>> Hello,<br>
>> Please review the following patch which adds -fasan (AddressSanitizer) flag<br>
>> to clang.<br>
>> (Mostly prepared by Chandler Carruth).<br>
>> The LLVM part of AddressSanitizer has been submitted as r144758.<br>
>> This patch will allow to enable AddressSanitizer from the clang command<br>
>> line.<br>
>> <a href="http://codereview.appspot.com/5396042" target="_blank">http://codereview.appspot.com/5396042</a><br>
>> Coming next in separate patches:<br>
>>   - a patch to clang driver to pass linker flags for AddressSanitizer<br>
>> (small)<br>
>>   - the run-time library and the tests (big)<br>
>> Thanks,<br>
>> --kcc<br>
><br>
> I would prefer -faddress-sanitizer over -fasan; shorter isn't really<br>
> better here.<br>
><br>
> +  if (Args.hasFlag(options::OPT_fasan, options::OPT_fno_asan, false)) {<br>
> +    CmdArgs.push_back("-DADDRESS_SANITIZER=1");<br>
> +  }<br>
> }<br>
><br>
> Why would a program need this?  Can a program that's aware of the<br>
> address sanitizer actually do anything usefully different?  Also,<br>
> since this define doesn't start with an underscore, it's possible this<br>
> could break a program using the identifier ADDRESS_SANITIZER for<br>
> something else.<br>
<br>
</div></div>It would be reasonable to make this a has_feature check.<br></blockquote><div><br></div></div></div><div>Is that supported by gcc? </div><div>I'd prefer to have a compiler-neutral thing. </div></div></blockquote>
<div><br></div><div>See <a href="http://clang.llvm.org/docs/LanguageExtensions.html#feature_check">http://clang.llvm.org/docs/LanguageExtensions.html#feature_check</a> -- it should be completely compiler neutral. It's just a mechanism that compilers can use to hide feature tests behind a known-safe macro, thereby avoiding keyword clobbers etc. GCC could be trivially extend to directly support this test pattern, and code can be written to work even with compilers that don't support it. </div>
</div>