This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add no_sanitize_undefined attribute (PR sanitizer/58411)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]