Title: [133793] trunk/Source/WTF
Revision
133793
Author
commit-qu...@webkit.org
Date
2012-11-07 12:35:27 -0800 (Wed, 07 Nov 2012)

Log Message

Function adoptNS and adoptCF should not generate memory leak diagnostic with Clang Static Analyzer.
https://bugs.webkit.org/show_bug.cgi?id=101420

Patch by Remy Demarest <rdemar...@apple.com> on 2012-11-07
Reviewed by Benjamin Poulain.

Add attributes to the adoptNS and adoptCF function arguments to remove Clang Static Analyzer diagnotics.
Define CF_RELEASES_ARGUMENT and NS_RELEASES_ARGUMENT if not available, use them in function declarations.

* wtf/RetainPtr.h:
(WTF::adoptCF): Adds CF_RELEASES_ARGUMENT attribute to the argument.
(WTF::adoptNS): Adds NS_RELEASES_ARGUMENT attribute to the argument.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (133792 => 133793)


--- trunk/Source/WTF/ChangeLog	2012-11-07 20:34:54 UTC (rev 133792)
+++ trunk/Source/WTF/ChangeLog	2012-11-07 20:35:27 UTC (rev 133793)
@@ -1,3 +1,17 @@
+2012-11-07  Remy Demarest  <rdemar...@apple.com>
+
+        Function adoptNS and adoptCF should not generate memory leak diagnostic with Clang Static Analyzer.
+        https://bugs.webkit.org/show_bug.cgi?id=101420
+
+        Reviewed by Benjamin Poulain.
+
+        Add attributes to the adoptNS and adoptCF function arguments to remove Clang Static Analyzer diagnotics.
+        Define CF_RELEASES_ARGUMENT and NS_RELEASES_ARGUMENT if not available, use them in function declarations.
+
+        * wtf/RetainPtr.h:
+        (WTF::adoptCF): Adds CF_RELEASES_ARGUMENT attribute to the argument.
+        (WTF::adoptNS): Adds NS_RELEASES_ARGUMENT attribute to the argument.
+
 2012-11-07  Christophe Dumez  <christophe.du...@intel.com>
 
         Add replaceWithLiteral() method to WTF::String

Modified: trunk/Source/WTF/wtf/RetainPtr.h (133792 => 133793)


--- trunk/Source/WTF/wtf/RetainPtr.h	2012-11-07 20:34:54 UTC (rev 133792)
+++ trunk/Source/WTF/wtf/RetainPtr.h	2012-11-07 20:35:27 UTC (rev 133793)
@@ -34,6 +34,14 @@
 #import <Foundation/Foundation.h>
 #endif
 
+#ifndef CF_RELEASES_ARGUMENT
+#define CF_RELEASES_ARGUMENT
+#endif
+
+#ifndef NS_RELEASES_ARGUMENT
+#define NS_RELEASES_ARGUMENT
+#endif
+
 namespace WTF {
 
     // Unlike most most of our smart pointers, RetainPtr can take either the pointer type or the pointed-to type,
@@ -257,13 +265,13 @@
         return a != b.get(); 
     }
 
-    template<typename T> inline RetainPtr<T> adoptCF(T) WARN_UNUSED_RETURN;
+    template<typename T> inline RetainPtr<T> adoptCF(T CF_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
     template<typename T> inline RetainPtr<T> adoptCF(T o)
     {
         return RetainPtr<T>(AdoptCF, o);
     }
 
-    template<typename T> inline RetainPtr<T> adoptNS(T) WARN_UNUSED_RETURN;
+    template<typename T> inline RetainPtr<T> adoptNS(T NS_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
     template<typename T> inline RetainPtr<T> adoptNS(T o)
     {
         return RetainPtr<T>(AdoptNS, o);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to