From: Jakub Jelinek Date: Wed, 26 Mar 2014 19:33:40 +0000 (+0100) Subject: ubsan.h (ubsan_create_data): Change second argument's type to const location_t *. X-Git-Tag: releases/gcc-4.9.0~288 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07d72e1df341f3c9a4b74c01e20b6360e2b99a59;p=thirdparty%2Fgcc.git ubsan.h (ubsan_create_data): Change second argument's type to const location_t *. * ubsan.h (ubsan_create_data): Change second argument's type to const location_t *. * ubsan.c (ubsan_source_location): If xloc.file is NULL, set it to _(""). (ubsan_create_data): Change second argument to const location_t *PLOC. Create Loc field whenever PLOC is non-NULL. (ubsan_instrument_unreachable, ubsan_expand_null_ifn, ubsan_build_overflow_builtin, instrument_bool_enum_load): Adjust callers. c-family/ * c-ubsan.c (ubsan_instrument_division, ubsan_instrument_shift, ubsan_instrument_vla, ubsan_instrument_return): Adjust ubsan_create_data callers. From-SVN: r208849 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aeb9c6f7821b..9477cf0d1f06 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,15 @@ 2014-03-26 Jakub Jelinek + * ubsan.h (ubsan_create_data): Change second argument's type + to const location_t *. + * ubsan.c (ubsan_source_location): If xloc.file is NULL, set it to + _(""). + (ubsan_create_data): Change second argument to const location_t *PLOC. + Create Loc field whenever PLOC is non-NULL. + (ubsan_instrument_unreachable, ubsan_expand_null_ifn, + ubsan_build_overflow_builtin, instrument_bool_enum_load): Adjust + callers. + PR other/59545 * real.c (real_to_integer2): Change type of low to UHWI. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 536b4fc4ca25..8d67d1288b37 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2014-03-26 Jakub Jelinek + + * c-ubsan.c (ubsan_instrument_division, ubsan_instrument_shift, + ubsan_instrument_vla, ubsan_instrument_return): Adjust + ubsan_create_data callers. + 2014-03-22 Jakub Jelinek PR debug/60603 diff --git a/gcc/c-family/c-ubsan.c b/gcc/c-family/c-ubsan.c index 610c010bddef..dc4d98147b32 100644 --- a/gcc/c-family/c-ubsan.c +++ b/gcc/c-family/c-ubsan.c @@ -73,7 +73,7 @@ ubsan_instrument_division (location_t loc, tree op0, tree op1) make sure it gets evaluated before the condition. */ t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), op0, t); tree data = ubsan_create_data ("__ubsan_overflow_data", - loc, NULL, + &loc, NULL, ubsan_type_descriptor (type, false), NULL_TREE); data = build_fold_addr_expr_loc (loc, data); @@ -142,7 +142,7 @@ ubsan_instrument_shift (location_t loc, enum tree_code code, make sure it gets evaluated before the condition. */ t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), op0, t); tree data = ubsan_create_data ("__ubsan_shift_data", - loc, NULL, + &loc, NULL, ubsan_type_descriptor (type0, false), ubsan_type_descriptor (type1, false), NULL_TREE); @@ -169,7 +169,7 @@ ubsan_instrument_vla (location_t loc, tree size) t = fold_build2 (LE_EXPR, boolean_type_node, size, build_int_cst (type, 0)); tree data = ubsan_create_data ("__ubsan_vla_data", - loc, NULL, + &loc, NULL, ubsan_type_descriptor (type, false), NULL_TREE); data = build_fold_addr_expr_loc (loc, data); @@ -185,7 +185,7 @@ ubsan_instrument_vla (location_t loc, tree size) tree ubsan_instrument_return (location_t loc) { - tree data = ubsan_create_data ("__ubsan_missing_return_data", loc, + tree data = ubsan_create_data ("__ubsan_missing_return_data", &loc, NULL, NULL_TREE); tree t = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_MISSING_RETURN); return build_call_expr_loc (loc, t, 1, build_fold_addr_expr_loc (loc, data)); diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 8a8c289aa236..ac40c85f56ba 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssanames.h" #include "asan.h" #include "gimplify-me.h" +#include "intl.h" /* Map from a tree to a VAR_DECL tree. */ @@ -238,6 +239,8 @@ ubsan_source_location (location_t loc) tree type = ubsan_source_location_type (); xloc = expand_location (loc); + if (xloc.file == NULL) + xloc.file = ""; /* Fill in the values from LOC. */ size_t len = strlen (xloc.file); @@ -404,7 +407,7 @@ ubsan_type_descriptor (tree type, bool want_pointer_type_p) pointer checking. */ tree -ubsan_create_data (const char *name, location_t loc, +ubsan_create_data (const char *name, const location_t *ploc, const struct ubsan_mismatch_data *mismatch, ...) { va_list args; @@ -412,17 +415,18 @@ ubsan_create_data (const char *name, location_t loc, tree fields[5]; vec *saved_args = NULL; size_t i = 0; + location_t loc = UNKNOWN_LOCATION; /* Firstly, create a pointer to type descriptor type. */ tree td_type = ubsan_type_descriptor_type (); TYPE_READONLY (td_type) = 1; td_type = build_pointer_type (td_type); - loc = LOCATION_LOCUS (loc); /* Create the structure type. */ ret = make_node (RECORD_TYPE); - if (loc != UNKNOWN_LOCATION) + if (ploc != NULL) { + loc = LOCATION_LOCUS (*ploc); fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE, ubsan_source_location_type ()); DECL_CONTEXT (fields[i]) = ret; @@ -481,7 +485,7 @@ ubsan_create_data (const char *name, location_t loc, tree ctor = build_constructor (ret, v); /* If desirable, set the __ubsan_source_location element. */ - if (loc != UNKNOWN_LOCATION) + if (ploc != NULL) CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, ubsan_source_location (loc)); size_t nelts = vec_safe_length (saved_args); @@ -513,7 +517,7 @@ tree ubsan_instrument_unreachable (location_t loc) { initialize_sanitizer_builtins (); - tree data = ubsan_create_data ("__ubsan_unreachable_data", loc, NULL, + tree data = ubsan_create_data ("__ubsan_unreachable_data", &loc, NULL, NULL_TREE); tree t = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE); return build_call_expr_loc (loc, t, 1, build_fold_addr_expr_loc (loc, data)); @@ -583,7 +587,7 @@ ubsan_expand_null_ifn (gimple_stmt_iterator gsi) const struct ubsan_mismatch_data m = { build_zero_cst (pointer_sized_int_node), ckind }; tree data = ubsan_create_data ("__ubsan_null_data", - loc, &m, + &loc, &m, ubsan_type_descriptor (TREE_TYPE (ptr), true), NULL_TREE); data = build_fold_addr_expr_loc (loc, data); @@ -658,7 +662,7 @@ tree ubsan_build_overflow_builtin (tree_code code, location_t loc, tree lhstype, tree op0, tree op1) { - tree data = ubsan_create_data ("__ubsan_overflow_data", loc, NULL, + tree data = ubsan_create_data ("__ubsan_overflow_data", &loc, NULL, ubsan_type_descriptor (lhstype, false), NULL_TREE); enum built_in_function fn_code; @@ -841,7 +845,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi) update_stmt (stmt); tree data = ubsan_create_data ("__ubsan_invalid_value_data", - loc, NULL, + &loc, NULL, ubsan_type_descriptor (type, false), NULL_TREE); data = build_fold_addr_expr_loc (loc, data); diff --git a/gcc/ubsan.h b/gcc/ubsan.h index e793ee3d431a..67cc6e915e39 100644 --- a/gcc/ubsan.h +++ b/gcc/ubsan.h @@ -38,7 +38,7 @@ struct ubsan_mismatch_data { extern void ubsan_expand_null_ifn (gimple_stmt_iterator); extern tree ubsan_instrument_unreachable (location_t); -extern tree ubsan_create_data (const char *, location_t, +extern tree ubsan_create_data (const char *, const location_t *, const struct ubsan_mismatch_data *, ...); extern tree ubsan_type_descriptor (tree, bool); extern tree ubsan_encode_value (tree, bool = false);