Hi!

Looks good, though I'd appreciate Joseph to look at this from the
option handling POV.  Some nits from me below:

On Fri, Jun 14, 2013 at 09:04:40PM +0200, Marek Polacek wrote:
> --- gcc/opts.c.mp     2013-06-14 19:23:02.300554991 +0200
> +++ gcc/opts.c        2013-06-14 20:00:30.377638168 +0200
> @@ -1405,6 +1405,64 @@ common_handle_option (struct gcc_options
>        opts->x_exit_after_options = true;
>        break;
>  
> +    case OPT_fsanitize_:
> +      {
> +     const char *p = arg;
> +     while (*p != 0)
> +       {
> +         static const struct
> +         {
> +           const char *const name;
> +           unsigned int flag;
> +           size_t len;
> +         } spec[] =
> +         {
> +           { "address", SANITIZE_ADDRESS, sizeof "address" - 1 },
> +           { "thread", SANITIZE_THREAD, sizeof "thread" - 1 },

For the trunk version I'd say the following 4 lines should be commented out,
and only enabled when you actually commit to trunk (or branch) corresponding
support.

> +           { "shift", SANITIZE_SHIFT, sizeof "shift" - 1 },
> +           { "integer-divide-by-zero", SANITIZE_DIVIDE,
> +             sizeof "integer-divide-by-zero" - 1 },
> +           { "undefined", SANITIZE_UNDEFINED, sizeof "undefined" - 1 },
> +           { NULL, 0, 0 }
> --- gcc/builtins.def.mp       2013-06-14 19:24:52.670944783 +0200
> +++ gcc/builtins.def  2013-06-14 20:00:30.384638196 +0200
> @@ -155,7 +155,8 @@ along with GCC; see the file COPYING3.
>  #define DEF_SANITIZER_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
>    DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,    \
>              true, true, true, ATTRS, true, \
> -            (flag_asan || flag_tsan))
> +            ((flag_sanitize & SANITIZE_ADDRESS) \
> +             || (flag_sanitize & SANITIZE_THREAD)))

Use (flag_sanitize & (SANITIZE_ADDRESS | SANITIZE_THREAD))
or just flag_sanitize instead?

> --- gcc/common.opt.mp 2013-06-14 19:24:52.671944787 +0200
> +++ gcc/common.opt    2013-06-14 20:00:30.389638216 +0200
> @@ -207,6 +207,10 @@ unsigned int help_columns
>  Variable
>  bool flag_opts_finished
>  
> +; What the sanitizer should instrument
> +Variable
> +unsigned int flag_sanitize

Can't you just add Var(flag_sanitize) to the line after fsanitize= ?

> +fsanitize=
> +Common Report Joined
> +Select what to sanitize
>  
>  fasynchronous-unwind-tables
>  Common Report Var(flag_asynchronous_unwind_tables) Optimization

        Jakub

Reply via email to