This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add no_sanitize_undefined attribute (PR sanitizer/58411)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Tue, 17 Sep 2013 18:51:59 +0200
- Subject: Re: [PATCH] Add no_sanitize_undefined attribute (PR sanitizer/58411)
- Authentication-results: sourceware.org; auth=none
- References: <20130917152422 dot GB15960 at redhat dot com> <20130917153751 dot GA1817 at tucnak dot redhat dot com> <20130917162652 dot GC15960 at redhat dot com> <20130917163438 dot GC1817 at tucnak dot redhat dot com> <20130917164525 dot GD15960 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Sep 17, 2013 at 06:45:25PM +0200, Marek Polacek wrote:
> --- gcc/builtins.c.mp2 2013-09-17 16:13:26.623161281 +0200
> +++ gcc/builtins.c 2013-09-17 18:42:11.338273135 +0200
> @@ -10313,7 +10313,10 @@ fold_builtin_0 (location_t loc, tree fnd
> return fold_builtin_classify_type (NULL_TREE);
>
> case BUILT_IN_UNREACHABLE:
> - if (flag_sanitize & SANITIZE_UNREACHABLE)
> + if (flag_sanitize & SANITIZE_UNREACHABLE
> + && current_function_decl != 0
> + && !lookup_attribute ("no_sanitize_undefined",
> + DECL_ATTRIBUTES (current_function_decl)))
> return ubsan_instrument_unreachable (loc);
> break;
>
I'd say you should instead use
&& (current_function_decl == NULL
|| !lookup_attribute (...))
so that you instrument even outside of fn bodies, just with no way to turn
it off in the code (only command line options).
Ok with that change.
Jakub