static-check-gc-attributes2
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
permissions -rw-r--r--
State as of now

diff --git a/xpcom/analysis/static-checking.js b/xpcom/analysis/static-checking.js
--- a/xpcom/analysis/static-checking.js
+++ b/xpcom/analysis/static-checking.js
@@ -445,20 +445,33 @@ StructStorageClass.prototype = {
         this._type.name == 'XPCOMGCObject')
       return null;
 
-    if (this._type.template &&
-        this._type.template.name == 'nsTArray_base' &&
-        this._type.template.arguments[0].name == 'GCAllocator')
-      return null;
+    let tmpl = this._type.template;
+    if (tmpl) {
+      if (tmpl.name == 'nsTArray_base' &&
+          tmpl.arguments[0].name == 'GCAllocator')
+        return null;
 
-    if (this._type.template &&
-        this._type.template.name == 'nsTArray' &&
-        this._type.template.arguments[1].name == 'GCAllocator')
-      return null;
+      if (tmpl.name == 'nsTArray' &&
+          tmpl.arguments[1].name == 'GCAllocator')
+        return null;
 
-    if (this._type.template &&
-	this._type.template.name == 'nsVoidArrayBase' &&
-	this._type.template.arguments[0].name == 'GCAllocator')
-      return null;
+      if (tmpl.name == 'nsVoidArrayBase' &&
+          tmpl.arguments[0].name == 'GCAllocator')
+        return null;
+
+      if (tmpl.name == 'nsAutoPtr') {
+        let innerclass = tmpl.arguments[0];
+        if (checkstack(stack, this._type))
+          return null;
+        
+        let stack2 = stack.concat(this._type);
+        m = getStorageClass(tmpl.arguments[0]).canSkipFinalization(stack2);
+        if (m != null)
+          return new StorageReason(this._type.loc, "nsAutoPtr with non-GC type must be finalized.", m);
+        
+        return null;
+      }
+    }
 
     if (hasOwnDestructor(this._type))
       return new StorageReason(this._type.loc, "%s %s has a destructor and is not annotated NS_FINALIZER_NOT_REQUIRED.".format(this._type.kind, this._type.name));