Cleanup a bit the clang attributes for type safety checking.

Cleanup r281861 by moving the definitions to their own section but
still leave the definitions out of lint.

In addition to the 'argument_with_type_tag' attribute, bring
'type_tag_for_datatype' which is necessary for annotating the
data types.
This commit is contained in:
Pedro F. Giffuni 2015-04-25 18:17:08 +00:00
parent 202379af84
commit 0e5e31a6c6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=281986

View File

@ -212,7 +212,6 @@
#define __unused
#define __packed
#define __aligned(x)
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
#define __section(x)
#define __weak
#else
@ -237,12 +236,6 @@
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
#endif
#if __has_attribute(argument_with_type_tag)
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
__attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
#else
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
#endif
#if defined(__INTEL_COMPILER)
#define __dead2 __attribute__((__noreturn__))
#define __pure2 __attribute__((__const__))
@ -775,6 +768,24 @@
#define __NO_TLS 1
#endif
/*
* Type Safety Checking
*
* Clang provides additional attributes to enable checking type safety
* properties that cannot be enforced by the C type system.
*/
#if __has_attribute(argument_with_type_tag) && \
__has_attribute(type_tag_for_datatype) && !defined(lint)
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
__attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
#define __datatype_type_tag(kind, type) \
__attribute__((__type_tag_for_datatype__(kind, type)))
#else
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
#define __datatype_type_tag(kind, type)
#endif
/*
* Lock annotations.
*