On Tue, Jan 10, 2017 at 03:02:49PM -0500, David Malcolm wrote:
> +/* Given ARG, an unrecognized sanitizer option, return the best
> +   matching sanitizer option, or NULL if there isn't one.  */
> +
> +static const char *
> +get_closest_sanitizer_option (const string_fragment &arg)
> +{
> +  best_match <const string_fragment &, const char*> bm (arg);
> +  for (int i = 0; sanitizer_opts[i].name != NULL; ++i)
> +    bm.consider (sanitizer_opts[i].name);
> +  return bm.get_best_meaningful_candidate ();

I think we shouldn't suggest invalid option combinations, so that means
passing code to get_closest_sanitizer_option (so that we know if it is
OPT_fsanitize_ or OPT_fsanitize_recover_) and a bool whether it is
the -fno-sanitize* or -fsanitize* (value).  Then we shouldn't add to
bm.consider:
1) for -fsanitize= (and not -fno-sanitize=) the "all" option
   (sanitizer_opts[i].flag == ~0U && code == OPT_fsanitize_ && value
   is a cheap test for that case)
2) for -fsanitize-recover= (and not -fno-sanitize-recover=) the
   non-recoverable options
   (!sanitizer_opts[i].can_recover && code == OPT_fsanitize_recover_ && value)
Otherwise it looks good to me.

        Jakub

Reply via email to