Bug 1117036 - Make it possible to optionally mark functions defined by MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME as MOZ_OVERRIDE; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 02 Jan 2015 01:10:35 -0500
changeset 235004 58f7805a959f3573d63284e4ab8546631c46cbf5
parent 235003 c3fc371864af3616973861ee140bc23f111a3743
child 235005 8afa48feba29925f22cdf4578ccef926c74f7739
push id346
push usermartin.thomson@gmail.com
push dateTue, 06 Jan 2015 00:23:07 +0000
reviewersfroydnj
bugs1117036
milestone37.0a1
Bug 1117036 - Make it possible to optionally mark functions defined by MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME as MOZ_OVERRIDE; r=froydnj
mfbt/RefPtr.h
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -156,21 +156,23 @@ public:
 
 private:
   mutable typename Conditional<Atomicity == AtomicRefCount,
                                Atomic<MozRefCountType>,
                                MozRefCountType>::Type mRefCnt;
 };
 
 #ifdef MOZ_REFCOUNTED_LEAK_CHECKING
-#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T) \
-  virtual const char* typeName() const { return #T; } \
-  virtual size_t typeSize() const { return sizeof(*this); }
+// Passing MOZ_OVERRIDE for the optional argument marks the typeName and
+// typeSize functions defined by this macro as overrides.
+#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T, ...) \
+  virtual const char* typeName() const __VA_ARGS__ { return #T; } \
+  virtual size_t typeSize() const __VA_ARGS__ { return sizeof(*this); }
 #else
-#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T)
+#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T, ...)
 #endif
 
 // Note that this macro is expanded unconditionally because it declares only
 // two small inline functions which will hopefully get eliminated by the linker
 // in non-leak-checking builds.
 #define MOZ_DECLARE_REFCOUNTED_TYPENAME(T) \
   const char* typeName() const { return #T; } \
   size_t typeSize() const { return sizeof(*this); }