x = NULL_TREE;
flag = SANITIZE_SI_OVERFLOW;
}
- else if (flag_sanitize_undefined_trap_on_error
- || (((flag_sanitize_recover & SANITIZE_DIVIDE) == 0)
+ else if ((((flag_sanitize_trap & SANITIZE_DIVIDE) == 0)
+ == ((flag_sanitize_trap & SANITIZE_SI_OVERFLOW) == 0))
+ && (((flag_sanitize_recover & SANITIZE_DIVIDE) == 0)
== ((flag_sanitize_recover & SANITIZE_SI_OVERFLOW) == 0)))
{
t = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, t, x);
make sure it gets evaluated before the condition. */
t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), unshare_expr (op0), t);
t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), unshare_expr (op1), t);
- if (flag_sanitize_undefined_trap_on_error)
+ if ((flag_sanitize_trap & flag) && x == NULL_TREE)
tt = build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
ubsan_type_descriptor (type), NULL_TREE,
NULL_TREE);
data = build_fold_addr_expr_loc (loc, data);
- enum built_in_function bcode
- = (flag_sanitize_recover & flag)
- ? BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW
- : BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW_ABORT;
- tt = builtin_decl_explicit (bcode);
- op0 = unshare_expr (op0);
- op1 = unshare_expr (op1);
- tt = build_call_expr_loc (loc, tt, 3, data, ubsan_encode_value (op0),
- ubsan_encode_value (op1));
- if (x)
+ if (flag_sanitize_trap & flag)
+ tt = build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_TRAP),
+ 0);
+ else
{
- bcode = (flag_sanitize_recover & SANITIZE_SI_OVERFLOW)
- ? BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW
- : BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW_ABORT;
- tree xt = builtin_decl_explicit (bcode);
+ enum built_in_function bcode
+ = (flag_sanitize_recover & flag)
+ ? BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW
+ : BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW_ABORT;
+ tt = builtin_decl_explicit (bcode);
op0 = unshare_expr (op0);
op1 = unshare_expr (op1);
- xt = build_call_expr_loc (loc, xt, 3, data, ubsan_encode_value (op0),
+ tt = build_call_expr_loc (loc, tt, 3, data, ubsan_encode_value (op0),
ubsan_encode_value (op1));
+ }
+ if (x)
+ {
+ tree xt;
+ if (flag_sanitize_trap & SANITIZE_SI_OVERFLOW)
+ xt = build_call_expr_loc (loc,
+ builtin_decl_explicit (BUILT_IN_TRAP),
+ 0);
+ else
+ {
+ enum built_in_function bcode
+ = (flag_sanitize_recover & SANITIZE_SI_OVERFLOW)
+ ? BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW
+ : BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW_ABORT;
+ xt = builtin_decl_explicit (bcode);
+ op0 = unshare_expr (op0);
+ op1 = unshare_expr (op1);
+ xt = build_call_expr_loc (loc, xt, 3, data,
+ ubsan_encode_value (op0),
+ ubsan_encode_value (op1));
+ }
x = fold_build3 (COND_EXPR, void_type_node, x, xt, void_node);
}
}
}
else
{
- if (flag_sanitize_undefined_trap_on_error
- || ((!(flag_sanitize_recover & SANITIZE_SHIFT_EXPONENT))
+ if (((!(flag_sanitize_trap & SANITIZE_SHIFT_EXPONENT))
+ == (!(flag_sanitize_trap & SANITIZE_SHIFT_BASE)))
+ && ((!(flag_sanitize_recover & SANITIZE_SHIFT_EXPONENT))
== (!(flag_sanitize_recover & SANITIZE_SHIFT_BASE))))
t = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, t, tt);
else
}
}
- if (flag_sanitize_undefined_trap_on_error)
+ if ((flag_sanitize_trap & recover_kind) && else_t == void_node)
tt = build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
NULL_TREE);
data = build_fold_addr_expr_loc (loc, data);
- enum built_in_function bcode
- = (flag_sanitize_recover & recover_kind)
- ? BUILT_IN_UBSAN_HANDLE_SHIFT_OUT_OF_BOUNDS
- : BUILT_IN_UBSAN_HANDLE_SHIFT_OUT_OF_BOUNDS_ABORT;
- tt = builtin_decl_explicit (bcode);
- op0 = unshare_expr (op0);
- op1 = unshare_expr (op1);
- tt = build_call_expr_loc (loc, tt, 3, data, ubsan_encode_value (op0),
- ubsan_encode_value (op1));
+ if (flag_sanitize_trap & recover_kind)
+ tt = build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_TRAP), 0);
+ else
+ {
+ enum built_in_function bcode
+ = (flag_sanitize_recover & recover_kind)
+ ? BUILT_IN_UBSAN_HANDLE_SHIFT_OUT_OF_BOUNDS
+ : BUILT_IN_UBSAN_HANDLE_SHIFT_OUT_OF_BOUNDS_ABORT;
+ tt = builtin_decl_explicit (bcode);
+ op0 = unshare_expr (op0);
+ op1 = unshare_expr (op1);
+ tt = build_call_expr_loc (loc, tt, 3, data, ubsan_encode_value (op0),
+ ubsan_encode_value (op1));
+ }
if (else_t != void_node)
{
- bcode = (flag_sanitize_recover & SANITIZE_SHIFT_BASE)
+ tree else_tt;
+ if (flag_sanitize_trap & SANITIZE_SHIFT_BASE)
+ else_tt
+ = build_call_expr_loc (loc,
+ builtin_decl_explicit (BUILT_IN_TRAP), 0);
+ else
+ {
+ enum built_in_function bcode
+ = (flag_sanitize_recover & SANITIZE_SHIFT_BASE)
? BUILT_IN_UBSAN_HANDLE_SHIFT_OUT_OF_BOUNDS
: BUILT_IN_UBSAN_HANDLE_SHIFT_OUT_OF_BOUNDS_ABORT;
- tree else_tt = builtin_decl_explicit (bcode);
- op0 = unshare_expr (op0);
- op1 = unshare_expr (op1);
- else_tt = build_call_expr_loc (loc, else_tt, 3, data,
- ubsan_encode_value (op0),
- ubsan_encode_value (op1));
+ else_tt = builtin_decl_explicit (bcode);
+ op0 = unshare_expr (op0);
+ op1 = unshare_expr (op1);
+ else_tt = build_call_expr_loc (loc, else_tt, 3, data,
+ ubsan_encode_value (op0),
+ ubsan_encode_value (op1));
+ }
else_t = fold_build3 (COND_EXPR, void_type_node, else_t,
else_tt, void_node);
}
tree t, tt;
t = fold_build2 (LE_EXPR, boolean_type_node, size, build_int_cst (type, 0));
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_VLA)
tt = build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
tree
ubsan_instrument_return (location_t loc)
{
- if (flag_sanitize_undefined_trap_on_error)
- return build_call_expr_loc
- /* pass_warn_function_return checks for BUILTINS_LOCATION. */
- (BUILTINS_LOCATION, builtin_decl_explicit (BUILT_IN_TRAP), 0);
+ if (flag_sanitize_trap & SANITIZE_RETURN)
+ /* pass_warn_function_return checks for BUILTINS_LOCATION. */
+ return build_call_expr_loc (BUILTINS_LOCATION,
+ builtin_decl_explicit (BUILT_IN_TRAP), 0);
tree data = ubsan_create_data ("__ubsan_missing_return_data", 1, &loc,
NULL_TREE, NULL_TREE);
Variable
unsigned int flag_sanitize_recover = (SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT | SANITIZE_KERNEL_ADDRESS | SANITIZE_KERNEL_HWADDRESS) & ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN)
+; What sanitizers should use __builtin_trap () instead of runtime diagnostics
+Variable
+unsigned int flag_sanitize_trap
+
; Flag whether a prefix has been added to dump_base_name
Variable
bool dump_base_name_prefixed = false
Common
This switch is deprecated; use -fsanitize-recover= instead.
+fsanitize-trap=
+Common Driver Joined
+Use traps instead of diagnostics of undefined behavior sanitizers.
+
+fsanitize-trap
+Common Driver
+
fsanitize-address-use-after-scope
Common Driver Var(flag_sanitize_address_use_after_scope) Init(0)
fsanitize-undefined-trap-on-error
-Common Driver Var(flag_sanitize_undefined_trap_on_error) Init(0)
-Use trap instead of a library function for undefined behavior sanitization.
+Common Driver Alias(fsanitize-trap)
+This switch is deprecated; use -fsanitize-trap= instead.
fasynchronous-unwind-tables
Common Var(flag_asynchronous_unwind_tables) Optimization
static bool
cp_ubsan_instrument_vptr_p (tree type)
{
- if (!flag_rtti || flag_sanitize_undefined_trap_on_error)
+ if (!flag_rtti || (flag_sanitize_trap & SANITIZE_VPTR))
return false;
if (!sanitize_flags_p (SANITIZE_VPTR))
-fprofile-exclude-files=@var{regex} @gol
-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} @gol
-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
+-fsanitize-trap -fsanitize-trap=@var{style} @gol
-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
-fsanitize-undefined-trap-on-error -fbounds-check @gol
-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} @gol
Enable sanitization of local variables to detect use-after-scope bugs.
The option sets @option{-fstack-reuse} to @samp{none}.
+@item -fsanitize-trap@r{[}=@var{opts}@r{]}
+@opindex fsanitize-trap
+@opindex fno-sanitize-trap
+The @option{-fsanitize-trap=} option instructs the compiler to
+report for sanitizers mentioned in comma-separated list of @var{opts}
+undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
+library routine. If this option is enabled for certain sanitizer,
+it takes precedence over the @option{-fsanitizer-recover=} for that
+sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
+of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
+
+The advantage of this is that the @code{libubsan} library is not needed
+and is not linked in, so this is usable even in freestanding environments.
+
+Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
+except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
+@option{-fsanitize=float-divide-by-zero} and
+@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
+specified, which enables it for @code{undefined} suboptions,
+@option{-fsanitize=float-cast-overflow},
+@option{-fsanitize=float-divide-by-zero} and
+@option{-fsanitize=bounds-strict}.
+If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
+and @code{-fsanitize=vptr} is enabled on the command line, the
+instrumentation is silently ignored as the instrumentation always needs
+@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
+
@item -fsanitize-undefined-trap-on-error
@opindex fsanitize-undefined-trap-on-error
-The @option{-fsanitize-undefined-trap-on-error} option instructs the compiler to
-report undefined behavior using @code{__builtin_trap} rather than
-a @code{libubsan} library routine. The advantage of this is that the
-@code{libubsan} library is not needed and is not linked in, so this
-is usable even in freestanding environments.
+The @option{-fsanitize-undefined-trap-on-error} option is deprecated
+equivalent of @option{-fsanitize-trap=all}.
@item -fsanitize-coverage=trace-pc
@opindex fsanitize-coverage=trace-pc
return (flag_sanitize & SANITIZE_THREAD) ? "" : NULL;
if (strcmp (argv[0], "undefined") == 0)
return ((flag_sanitize
- & (SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT))
- && !flag_sanitize_undefined_trap_on_error) ? "" : NULL;
+ & ~flag_sanitize_trap
+ & (SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT)))
+ ? "" : NULL;
if (strcmp (argv[0], "leak") == 0)
return ((flag_sanitize
& (SANITIZE_ADDRESS | SANITIZE_LEAK | SANITIZE_THREAD))
error_at (loc, "%<-fsanitize-recover=%s%> is not supported",
sanitizer_opts[i].name);
+ /* Check -fsanitize-trap option. */
+ for (int i = 0; sanitizer_opts[i].name != NULL; ++i)
+ if ((opts->x_flag_sanitize_trap & sanitizer_opts[i].flag)
+ && !sanitizer_opts[i].can_trap
+ /* Allow -fsanitize-trap=all or -fsanitize-trap=undefined
+ to set flag_sanitize_trap & SANITIZE_VPTR bit which will
+ effectively disable -fsanitize=vptr, just disallow
+ explicit -fsanitize-trap=vptr. */
+ && sanitizer_opts[i].flag != SANITIZE_VPTR)
+ error_at (loc, "%<-fsanitize-trap=%s%> is not supported",
+ sanitizer_opts[i].name);
+
/* When instrumenting the pointers, we don't want to remove
the null pointer checks. */
if (opts->x_flag_sanitize & (SANITIZE_NULL | SANITIZE_NONNULL_ATTRIBUTE
/* -f{,no-}sanitize{,-recover}= suboptions. */
const struct sanitizer_opts_s sanitizer_opts[] =
{
-#define SANITIZER_OPT(name, flags, recover) \
- { #name, flags, sizeof #name - 1, recover }
- SANITIZER_OPT (address, (SANITIZE_ADDRESS | SANITIZE_USER_ADDRESS), true),
+#define SANITIZER_OPT(name, flags, recover, trap) \
+ { #name, flags, sizeof #name - 1, recover, trap }
+ SANITIZER_OPT (address, (SANITIZE_ADDRESS | SANITIZE_USER_ADDRESS), true,
+ false),
SANITIZER_OPT (hwaddress, (SANITIZE_HWADDRESS | SANITIZE_USER_HWADDRESS),
- true),
+ true, false),
SANITIZER_OPT (kernel-address, (SANITIZE_ADDRESS | SANITIZE_KERNEL_ADDRESS),
- true),
+ true, false),
SANITIZER_OPT (kernel-hwaddress,
(SANITIZE_HWADDRESS | SANITIZE_KERNEL_HWADDRESS),
+ true, false),
+ SANITIZER_OPT (pointer-compare, SANITIZE_POINTER_COMPARE, true, false),
+ SANITIZER_OPT (pointer-subtract, SANITIZE_POINTER_SUBTRACT, true, false),
+ SANITIZER_OPT (thread, SANITIZE_THREAD, false, false),
+ SANITIZER_OPT (leak, SANITIZE_LEAK, false, false),
+ SANITIZER_OPT (shift, SANITIZE_SHIFT, true, true),
+ SANITIZER_OPT (shift-base, SANITIZE_SHIFT_BASE, true, true),
+ SANITIZER_OPT (shift-exponent, SANITIZE_SHIFT_EXPONENT, true, true),
+ SANITIZER_OPT (integer-divide-by-zero, SANITIZE_DIVIDE, true, true),
+ SANITIZER_OPT (undefined, SANITIZE_UNDEFINED, true, true),
+ SANITIZER_OPT (unreachable, SANITIZE_UNREACHABLE, false, true),
+ SANITIZER_OPT (vla-bound, SANITIZE_VLA, true, true),
+ SANITIZER_OPT (return, SANITIZE_RETURN, false, true),
+ SANITIZER_OPT (null, SANITIZE_NULL, true, true),
+ SANITIZER_OPT (signed-integer-overflow, SANITIZE_SI_OVERFLOW, true, true),
+ SANITIZER_OPT (bool, SANITIZE_BOOL, true, true),
+ SANITIZER_OPT (enum, SANITIZE_ENUM, true, true),
+ SANITIZER_OPT (float-divide-by-zero, SANITIZE_FLOAT_DIVIDE, true, true),
+ SANITIZER_OPT (float-cast-overflow, SANITIZE_FLOAT_CAST, true, true),
+ SANITIZER_OPT (bounds, SANITIZE_BOUNDS, true, true),
+ SANITIZER_OPT (bounds-strict, SANITIZE_BOUNDS | SANITIZE_BOUNDS_STRICT, true,
true),
- SANITIZER_OPT (pointer-compare, SANITIZE_POINTER_COMPARE, true),
- SANITIZER_OPT (pointer-subtract, SANITIZE_POINTER_SUBTRACT, true),
- SANITIZER_OPT (thread, SANITIZE_THREAD, false),
- SANITIZER_OPT (leak, SANITIZE_LEAK, false),
- SANITIZER_OPT (shift, SANITIZE_SHIFT, true),
- SANITIZER_OPT (shift-base, SANITIZE_SHIFT_BASE, true),
- SANITIZER_OPT (shift-exponent, SANITIZE_SHIFT_EXPONENT, true),
- SANITIZER_OPT (integer-divide-by-zero, SANITIZE_DIVIDE, true),
- SANITIZER_OPT (undefined, SANITIZE_UNDEFINED, true),
- SANITIZER_OPT (unreachable, SANITIZE_UNREACHABLE, false),
- SANITIZER_OPT (vla-bound, SANITIZE_VLA, true),
- SANITIZER_OPT (return, SANITIZE_RETURN, false),
- SANITIZER_OPT (null, SANITIZE_NULL, true),
- SANITIZER_OPT (signed-integer-overflow, SANITIZE_SI_OVERFLOW, true),
- SANITIZER_OPT (bool, SANITIZE_BOOL, true),
- SANITIZER_OPT (enum, SANITIZE_ENUM, true),
- SANITIZER_OPT (float-divide-by-zero, SANITIZE_FLOAT_DIVIDE, true),
- SANITIZER_OPT (float-cast-overflow, SANITIZE_FLOAT_CAST, true),
- SANITIZER_OPT (bounds, SANITIZE_BOUNDS, true),
- SANITIZER_OPT (bounds-strict, SANITIZE_BOUNDS | SANITIZE_BOUNDS_STRICT, true),
- SANITIZER_OPT (alignment, SANITIZE_ALIGNMENT, true),
- SANITIZER_OPT (nonnull-attribute, SANITIZE_NONNULL_ATTRIBUTE, true),
+ SANITIZER_OPT (alignment, SANITIZE_ALIGNMENT, true, true),
+ SANITIZER_OPT (nonnull-attribute, SANITIZE_NONNULL_ATTRIBUTE, true, true),
SANITIZER_OPT (returns-nonnull-attribute, SANITIZE_RETURNS_NONNULL_ATTRIBUTE,
- true),
- SANITIZER_OPT (object-size, SANITIZE_OBJECT_SIZE, true),
- SANITIZER_OPT (vptr, SANITIZE_VPTR, true),
- SANITIZER_OPT (pointer-overflow, SANITIZE_POINTER_OVERFLOW, true),
- SANITIZER_OPT (builtin, SANITIZE_BUILTIN, true),
- SANITIZER_OPT (shadow-call-stack, SANITIZE_SHADOW_CALL_STACK, false),
- SANITIZER_OPT (all, ~0U, true),
+ true, true),
+ SANITIZER_OPT (object-size, SANITIZE_OBJECT_SIZE, true, true),
+ SANITIZER_OPT (vptr, SANITIZE_VPTR, true, false),
+ SANITIZER_OPT (pointer-overflow, SANITIZE_POINTER_OVERFLOW, true, true),
+ SANITIZER_OPT (builtin, SANITIZE_BUILTIN, true, true),
+ SANITIZER_OPT (shadow-call-stack, SANITIZE_SHADOW_CALL_STACK, false, false),
+ SANITIZER_OPT (all, ~0U, true, true),
#undef SANITIZER_OPT
- { NULL, 0U, 0UL, false }
+ { NULL, 0U, 0UL, false, false }
};
/* -fzero-call-used-regs= suboptions. */
/* Given ARG, an unrecognized sanitizer option, return the best
matching sanitizer option, or NULL if there isn't one.
OPTS is array of candidate sanitizer options.
- CODE is OPT_fsanitize_ or OPT_fsanitize_recover_.
+ CODE is OPT_fsanitize_, OPT_fsanitize_recover_ or OPT_fsanitize_trap_.
VALUE is non-zero for the regular form of the option, zero
for the "no-" form (e.g. "-fno-sanitize-recover="). */
&& value)
continue;
+ /* For -fsanitize-trap= (and not -fno-sanitize-trap=),
+ don't offer the non-trapping options. */
+ if (code == OPT_fsanitize_trap_
+ && !opts[i].can_trap
+ && value)
+ continue;
+
bm.consider (opts[i].name);
}
return bm.get_best_meaningful_candidate ();
if (complain)
error_at (loc, "%<-fsanitize=all%> option is not valid");
}
- else
+ else if (code == OPT_fsanitize_recover_)
flags |= ~(SANITIZE_THREAD | SANITIZE_LEAK
| SANITIZE_UNREACHABLE | SANITIZE_RETURN
| SANITIZE_SHADOW_CALL_STACK);
+ else /* if (code == OPT_fsanitize_trap_) */
+ flags |= (SANITIZE_UNDEFINED
+ | SANITIZE_UNDEFINED_NONDEFAULT);
}
else if (value)
{
&& sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
flags |= (SANITIZE_UNDEFINED
& ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN));
+ else if (code == OPT_fsanitize_trap_
+ && sanitizer_opts[i].flag == SANITIZE_VPTR)
+ error_at (loc, "%<-fsanitize-trap=%s%> is not supported",
+ sanitizer_opts[i].name);
else
flags |= sanitizer_opts[i].flag;
}
const char *suffix;
if (code == OPT_fsanitize_recover_)
suffix = "-recover";
+ else if (code == OPT_fsanitize_trap_)
+ suffix = "-trap";
else
suffix = "";
opts->x_flag_sanitize_recover, value, true);
break;
+ case OPT_fsanitize_trap_:
+ opts->x_flag_sanitize_trap
+ = parse_sanitizer_options (arg, loc, code,
+ opts->x_flag_sanitize_trap, value, true);
+ break;
+
case OPT_fasan_shadow_offset_:
/* Deferred. */
break;
&= ~(SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT);
break;
+ case OPT_fsanitize_trap:
+ if (value)
+ opts->x_flag_sanitize_trap
+ |= (SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT);
+ else
+ opts->x_flag_sanitize_trap
+ &= ~(SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT);
+ break;
+
case OPT_O:
case OPT_Os:
case OPT_Ofast:
unsigned int flag;
size_t len;
bool can_recover;
+ bool can_trap;
} sanitizer_opts[];
extern const struct zero_call_used_regs_opts_s
stmts have same location. */
else if (integer_zerop (align))
remove = (flag_sanitize_recover & SANITIZE_NULL) == 0
- || flag_sanitize_undefined_trap_on_error
+ || (flag_sanitize_trap & SANITIZE_NULL) != 0
|| gimple_location (g) == gimple_location (stmt);
else if (tree_int_cst_le (cur_align, align))
remove = (flag_sanitize_recover & SANITIZE_ALIGNMENT) == 0
- || flag_sanitize_undefined_trap_on_error
+ || (flag_sanitize_trap & SANITIZE_ALIGNMENT) != 0
|| gimple_location (g) == gimple_location (stmt);
if (!remove && gimple_bb (g) == gimple_bb (stmt)
/* Limit this to known non-strict alignment targets. */
/* { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } */
-/* { dg-options "-O -fsanitize=alignment -fsanitize-undefined-trap-on-error -Wno-address-of-packed-member -fdump-tree-sanopt-details" } */
+/* { dg-options "-O -fsanitize=alignment -fsanitize-trap=alignment -Wno-address-of-packed-member -fdump-tree-sanopt-details" } */
/* { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } */
/* { dg-shouldfail "ubsan" } */
/* { dg-do run } */
-/* { dg-options "-fsanitize=signed-integer-overflow -fsanitize-undefined-trap-on-error -Wno-overflow" } */
+/* { dg-options "-fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -Wno-overflow" } */
#define INT_MIN (-__INT_MAX__ - 1)
/* { dg-do run } */
/* { dg-shouldfail "ubsan" } */
-/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+/* { dg-options "-fsanitize=undefined -fsanitize-trap=all" } */
int q, r;
void *a, *b, *c = (void *) &q, *d, *e, *f = (void *) &q, *g, *h;
/* { dg-do run } */
-/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable -fsanitize-undefined-trap-on-error" } */
+/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable -fsanitize-trap=undefined" } */
/* { dg-shouldfail "ubsan" } */
#define INT_MAX __INT_MAX__
/* { dg-do run } */
-/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+/* { dg-options "-fsanitize=undefined -fsanitize-trap=undefined" } */
unsigned int __attribute__((noinline,noclone))
foo (unsigned int x)
/* { dg-do run } */
-/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+/* { dg-options "-fsanitize=undefined -fsanitize-trap=undefined" } */
int __attribute__((noinline,noclone))
h(int a)
/* PR sanitizer/80932 */
/* { dg-do run } */
-/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+/* { dg-options "-fsanitize=undefined -fno-sanitize-trap=all -fsanitize-trap=shift,undefined" } */
int x = 1;
gimple *g;
location_t loc = gimple_location (gsi_stmt (*gsi));
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_UNREACHABLE)
g = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
/* Generate __ubsan_handle_out_of_bounds call. */
*gsi = gsi_after_labels (then_bb);
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_BOUNDS)
g = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
/* Put the ubsan builtin call into the newly created BB. */
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & ((check_align ? SANITIZE_ALIGNMENT + 0 : 0)
+ | (check_null ? SANITIZE_NULL + 0 : 0)))
g = gimple_build_call (builtin_decl_implicit (BUILT_IN_TRAP), 0);
else
{
}
/* Generate __ubsan_handle_type_mismatch call. */
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_OBJECT_SIZE)
g = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
}
/* Put the ubsan builtin call into the newly created BB. */
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_POINTER_OVERFLOW)
g = gimple_build_call (builtin_decl_implicit (BUILT_IN_TRAP), 0);
else
{
ubsan_build_overflow_builtin (tree_code code, location_t loc, tree lhstype,
tree op0, tree op1, tree *datap)
{
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_SI_OVERFLOW)
return build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_TRAP), 0);
tree data;
}
gsi2 = gsi_after_labels (then_bb);
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & (TREE_CODE (type) == BOOLEAN_TYPE
+ ? SANITIZE_BOOL : SANITIZE_ENUM))
g = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
if (integer_zerop (t))
return NULL_TREE;
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_FLOAT_CAST)
fn = build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
gsi_insert_after (gsi, g, GSI_NEW_STMT);
*gsi = gsi_after_labels (then_bb);
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_NONNULL_ATTRIBUTE)
g = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
gsi_insert_after (gsi, g, GSI_NEW_STMT);
*gsi = gsi_after_labels (then_bb);
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_RETURNS_NONNULL_ATTRIBUTE)
g = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
gsi_insert_after (gsi, g, GSI_NEW_STMT);
*gsi = gsi_after_labels (then_bb);
- if (flag_sanitize_undefined_trap_on_error)
+ if (flag_sanitize_trap & SANITIZE_BUILTIN)
g = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{