Author: pfg
Date: Sat Apr 25 18:17:08 2015
New Revision: 281986
URL: https://svnweb.freebsd.org/changeset/base/281986

Log:
  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.

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==============================================================================
--- head/sys/sys/cdefs.h        Sat Apr 25 16:15:01 2015        (r281985)
+++ head/sys/sys/cdefs.h        Sat Apr 25 18:17:08 2015        (r281986)
@@ -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
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to