diff options
Diffstat (limited to 'gcc/asan.h')
-rw-r--r-- | gcc/asan.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/asan.h b/gcc/asan.h index 86b295583cb..efc517e0556 100644 --- a/gcc/asan.h +++ b/gcc/asan.h @@ -157,4 +157,24 @@ asan_protect_stack_decl (tree decl) || (asan_sanitize_use_after_scope () && TREE_ADDRESSABLE (decl))); } +/* Return true when flag_sanitize & FLAG is non-zero. If FN is non-null, + remove all flags mentioned in "no_sanitize" of DECL_ATTRIBUTES. */ + +static inline bool +sanitize_flags_p (unsigned int flag, const_tree fn = current_function_decl) +{ + unsigned int result_flags = flag_sanitize & flag; + if (result_flags == 0) + return false; + + if (fn != NULL_TREE) + { + tree value = lookup_attribute ("no_sanitize", DECL_ATTRIBUTES (fn)); + if (value) + result_flags &= ~tree_to_uhwi (TREE_VALUE (value)); + } + + return result_flags; +} + #endif /* TREE_ASAN */ |