[cfe-commits] [PATCH] Add -fsanitize= command line argument to control -fcatch-undefined-behavior, -faddress-sanitizer, and -fthread-sanitizer

Chandler Carruth chandlerc at google.com
Thu Nov 1 23:50:46 PDT 2012

On Thu, Nov 1, 2012 at 11:01 PM, Dmitry Vyukov <dvyukov at google.com> wrote:
> On Fri, Nov 2, 2012 at 4:51 AM, Richard Smith <richard at metafoo.co.uk> wrote:
>> Hi,
>> The attached patch series adds a
>> -fsanitize=sanitizer1,sanitizer2,sanitizer3 command-line option to
>> Clang (and a corresponding -fno-sanitize=...). This works as follows
>> for the driver options:
>>   -faddress-sanitizer becomes a synonym for -fsanitize=address
>>   -fno-address-sanitizer becomes a synonym for -fno-sanitize=address
>>   -fthread-sanitizer becomes a synonym for -fsanitize=thread
>>   -fno-thread-sanitizer becomes a synonym for -fno-sanitize=thread
>>   -fcatch-undefined-behavior becomes a synonym for -fsanitize=undefined
>>   -fsanitize=undefined is expanded by the driver into a list of
>> individual undefined behavior sanitizers
>> The -cc1 interface is deliberately very simplistic: it loses support
>> for the existing flags, and instead only supports -fsanitize=..., and
>> only supports naming the individual checks (and not groups like
>> -fsanitize=undefined).
>> Patch 1 just renames the existing ASan and TSan LangOptions to follow
>> the naming convention used by the later patches.
>> Patch 2 adds support to the driver and frontend for parsing
>> -fsanitize, converting the other options to it, and filling in
>> LangOptions.
>> Patch 3 uses the -fsanitize=... values to enable/disable the existing
>> -fcatch-undefined-behavior checks, and removes frontend support for
>> the other options.
> +Diego,David
> And if/when we add MemorySanitizer, can we add new alias -fmemory-sanitizer?
> I am asking because we are in the process of committing asan/tsan to gcc,
> and we want to preserve consistency between clang and gcc. Gcc uses
> -address/thread-sanitizer.

Why not use a similar flag scheme to the one Richard proposes in GCC?
The only reason (in my mind) to support aliases like this is for
backwards compatibility, and there isn't any such concern for
MemorySanitizer, and in fact there shouldn't be much of a concern for

> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

More information about the cfe-commits mailing list