summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2015-04-25 18:17:08 +0000
committerpfg <pfg@FreeBSD.org>2015-04-25 18:17:08 +0000
commit975079836aa6c99686ca4947b8a10db26ff8267f (patch)
tree70aae14834f6e36833f01e1de0df0f6c94da14cb
parent9da00f2a97fc238a88291c3bb9b68c9d911c202f (diff)
downloadFreeBSD-src-975079836aa6c99686ca4947b8a10db26ff8267f.zip
FreeBSD-src-975079836aa6c99686ca4947b8a10db26ff8267f.tar.gz
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.
-rw-r--r--sys/sys/cdefs.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 64795f2..ab7d59d 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -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__))
@@ -776,6 +769,24 @@
#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.
*
* Clang provides support for doing basic thread-safety tests at
OpenPOWER on IntegriCloud