Bug 1114696 - Add MOZ_STRONG_REF and MOZ_WEAK_REF annotations; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 22 Dec 2014 18:16:55 -0500
changeset 220975 6ceabcdac1d46b270ae1a7d80161118d3e5a25f5
parent 220974 682c3ff54faea4254118b5bec68d334d25721ded
child 220976 9280b99e3475a1e33fb269cb875282f35e4a40cb
push id53239
push usereakhgari@mozilla.com
push dateMon, 22 Dec 2014 23:17:12 +0000
treeherdermozilla-inbound@6ceabcdac1d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1114696
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1114696 - Add MOZ_STRONG_REF and MOZ_WEAK_REF annotations; r=froydnj
mfbt/Attributes.h
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -507,31 +507,41 @@
  *   value is allocated on the heap, and will as a result check such allocations
  *   during MOZ_STACK_CLASS and MOZ_NONHEAP_CLASS annotation checking.
  * MOZ_IMPLICIT: Applies to constructors. Implicit conversion constructors
  *   are disallowed by default unless they are marked as MOZ_IMPLICIT. This
  *   attribute must be used for constructors which intend to provide implicit
  *   conversions.
  * MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT: Applies to functions. Makes it a compile
  *   time error to pass arithmetic expressions on variables to the function.
+ * MOZ_STRONG_REF: Applies to declarations of pointer types.  This attribute
+ *   tells the compiler that the raw pointer is a strong reference, and that
+ *   property is somehow enforced by the code.  This can make the compiler
+ *   ignore these pointers when validating the usage of pointers otherwise.
+ * MOZ_WEAK_REF: Applies to declarations of pointer types.  This attribute
+ *   tells the compiler that the raw pointer is a weak reference, and that
+ *   property is somehow enforced by the code.  This can make the compiler
+ *   ignore these pointers when validating the usage of pointers otherwise.
  */
 #ifdef MOZ_CLANG_PLUGIN
 #  define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
 #  define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))
 #  define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
 #  define MOZ_TRIVIAL_CTOR_DTOR __attribute__((annotate("moz_trivial_ctor_dtor")))
 #  ifdef DEBUG
      /* in debug builds, these classes do have non-trivial constructors. */
 #    define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class")))
 #  else
 #    define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class"))) \
             MOZ_TRIVIAL_CTOR_DTOR
 #  endif
 #  define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
 #  define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg")))
+#  define MOZ_STRONG_REF __attribute__((annotate("moz_strong_ref")))
+#  define MOZ_WEAK_REF __attribute__((annotate("moz_weak_ref")))
 /*
  * It turns out that clang doesn't like void func() __attribute__ {} without a
  * warning, so use pragmas to disable the warning. This code won't work on GCC
  * anyways, so the warning is safe to ignore.
  */
 #  define MOZ_HEAP_ALLOCATOR \
     _Pragma("clang diagnostic push") \
     _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
@@ -541,16 +551,18 @@
 #  define MOZ_MUST_OVERRIDE /* nothing */
 #  define MOZ_STACK_CLASS /* nothing */
 #  define MOZ_NONHEAP_CLASS /* nothing */
 #  define MOZ_TRIVIAL_CTOR_DTOR /* nothing */
 #  define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS /* nothing */
 #  define MOZ_IMPLICIT /* nothing */
 #  define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT /* nothing */
 #  define MOZ_HEAP_ALLOCATOR /* nothing */
+#  define MOZ_STRONG_REF /* nothing */
+#  define MOZ_WEAK_REF /* nothing */
 #endif /* MOZ_CLANG_PLUGIN */
 
 /*
  * MOZ_THIS_IN_INITIALIZER_LIST is used to avoid a warning when we know that
  * it's safe to use 'this' in an initializer list.
  */
 #ifdef _MSC_VER
 #  define MOZ_THIS_IN_INITIALIZER_LIST() \