aboutsummaryrefslogtreecommitdiff
path: root/gcc/ubsan.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-01-08 16:27:22 -0500
committerJason Merrill <jason@gcc.gnu.org>2015-01-08 16:27:22 -0500
commitf5481fc443060065cde9ed7bc6f3fd83bc1ecc4c (patch)
treecbafc576a2a3a432c0727f066088eb9aa5369156 /gcc/ubsan.c
parent46621807e9bf7bc94302cda27852e33a3c766112 (diff)
downloadgcc-f5481fc443060065cde9ed7bc6f3fd83bc1ecc4c.zip
gcc-f5481fc443060065cde9ed7bc6f3fd83bc1ecc4c.tar.gz
gcc-f5481fc443060065cde9ed7bc6f3fd83bc1ecc4c.tar.bz2
ubsan.c (do_ubsan_in_current_function): New.
gcc/ * ubsan.c (do_ubsan_in_current_function): New. (pass_ubsan::gate): Use it. * ubsan.h: Declare it. * convert.c (convert_to_integer): Use it. gcc/c-family/ * c-ubsan.c (ubsan_maybe_instrument_array_ref): Use do_ubsan_in_current_function. (ubsan_maybe_instrument_reference_or_call): Likewise. * c-ubsan.h: Declare it. gcc/cp/ * cp-gimplify.c (cp_genericize): Use do_ubsan_in_current_function. * decl.c (compute_array_index_type): Likewise. * init.c (build_vec_init): Likewise. * typeck.c (cp_build_binary_op): Likewise. From-SVN: r219360
Diffstat (limited to 'gcc/ubsan.c')
-rw-r--r--gcc/ubsan.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 5c9355a..7dae967 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -1648,6 +1648,16 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs)
gsi_insert_before (gsi, g, GSI_SAME_STMT);
}
+/* True if we want to play UBSan games in the current function. */
+
+bool
+do_ubsan_in_current_function ()
+{
+ return (current_function_decl != NULL_TREE
+ && !lookup_attribute ("no_sanitize_undefined",
+ DECL_ATTRIBUTES (current_function_decl)));
+}
+
namespace {
const pass_data pass_data_ubsan =
@@ -1679,9 +1689,7 @@ public:
| SANITIZE_NONNULL_ATTRIBUTE
| SANITIZE_RETURNS_NONNULL_ATTRIBUTE
| SANITIZE_OBJECT_SIZE)
- && current_function_decl != NULL_TREE
- && !lookup_attribute ("no_sanitize_undefined",
- DECL_ATTRIBUTES (current_function_decl));
+ && do_ubsan_in_current_function ();
}
virtual unsigned int execute (function *);