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

Richard Smith richard at metafoo.co.uk
Thu Nov 1 17:51:50 PDT 2012


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.

Please review! I'd like to get this in for the 3.2 release.

Thanks!
Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsanitize-1-rename-asan-tsan-langopts.diff
Type: application/octet-stream
Size: 5686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121101/e8dd138d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsanitize-2-argument-parsing.diff
Type: application/octet-stream
Size: 22040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121101/e8dd138d/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsanitize-3-use-values.diff
Type: application/octet-stream
Size: 23518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121101/e8dd138d/attachment-0002.obj>


More information about the cfe-commits mailing list