This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH v2] Offer suggestions for unrecognized sanitizer options (PR driver/78877)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Jan 2017 09:30:04 +0100
- Subject: Re: [PATCH v2] Offer suggestions for unrecognized sanitizer options (PR driver/78877)
- Authentication-results: sourceware.org; auth=none
- References: <1484099246-25276-1-git-send-email-dmalcolm@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Jan 10, 2017 at 08:47:26PM -0500, David Malcolm wrote:
> + /* For -fsanitize-recover= (and not -fno-sanitize-recover=),
> + don't offer the non-recoverable options. */
> + if (!sanitizer_opts[i].can_recover && code == OPT_fsanitize_recover_
> + && value)
If a condition doesn't fit on a single line, usually we want to put every
subcondition on separate line, so:
if (!sanitizer_opts[i].can_recover
&& code == OPT_fsanitize_recover_
&& value)
> + continue;
> +
> + bm.consider (sanitizer_opts[i].name);
> + }
> + return bm.get_best_meaningful_candidate ();
> +}
> +
> /* Parse comma separated sanitizer suboptions from P for option SCODE,
> adjust previous FLAGS and return new ones. If COMPLAIN is false,
> don't issue diagnostics. */
> @@ -1572,8 +1629,21 @@ parse_sanitizer_options (const char *p, location_t loc, int scode,
> }
>
> if (! found && complain)
> - error_at (loc, "unrecognized argument to -fsanitize%s= option: %q.*s",
> - code == OPT_fsanitize_ ? "" : "-recover", (int) len, p);
> + {
> + const char *optname
> + = code == OPT_fsanitize_ ? "-fsanitize" : "-fsanitize-recover";
Because value matters too, I think it would be nice to also differentiate
between -fsanitize and -fno-sanitize in the diagnostics (I know the old
code didn't do that either).
So use -f%ssanitize%s= and corresponding
value ? "" : "no-", code == OPT_fsanitize_ ? "" : "-recover"
This is normally against translation rules, but I think translators should
not translate the option name and thus -f%ssanitize%s= should be kept as is
somewhere in the translation string.
> + const char *hint
> + = get_closest_sanitizer_option (string_fragment (p, len),
> + code, value);
> +
> + if (hint)
> + error_at (loc, "unrecognized argument to %s= option: %q.*s;"
> + " did you mean %qs",
> + optname, (int) len, p, hint);
> + else
> + error_at (loc, "unrecognized argument to %s= option: %q.*s",
> + optname, (int) len, p);
> + }
Ok for trunk with those changes.
Jakub