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 05:24:22PM +0200, Marek Polacek wrote:
> This patch adds the no_sanitize_undefined attribute, so the user can tell
> that a particular function should be ignored by ubsan.

Does this correspond to some llvm attribute?

> --- gcc/builtins.c.mp2	2013-09-17 16:13:26.623161281 +0200
> +++ gcc/builtins.c	2013-09-17 16:15:20.846557451 +0200
> @@ -10313,7 +10313,9 @@ 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
> +	  && !lookup_attribute ("no_sanitize_undefined",
> +				DECL_ATTRIBUTES (current_function_decl)))
>  	return ubsan_instrument_unreachable (loc);
>        break;

I wonder if current_function_decl couldn't be NULL here, say if
__builtin_unreachable () appears in C++ global var initializers or similar.

	Jakub


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