XPCOMGC/Static Checker

< XPCOMGC
Revision as of 07:59, 12 December 2007 by Brendan (talk | contribs) (may => must nits)

Taras and/or dmandelin will work on an extended GCC which will provide additional static-checking capabilities for the Mozilla codebase. The following is a preliminary set of static checks to perform for the XPCOMGC codebase. Initially many of these checks will fail and should be warnings, not hard errors.

  • If a class inherits from XPCOMGCFinalizedObject, the left-most base other than XPCOMGCFinalizedObject must be MMgc::GCFinalizedBase
  • Certain classes may be allocated only on the stack or on the heap... bsmedberg is happy to annotate these classes. TODO: how to annotate? It's important to catch instances where these classes are members of other classes being heap or stack allocated. And it's important that in both these cases, static allocations are disallowed.
  • For any class which inherits from MMgc::GCFinalizedBase:
    • The destructor must not dereference any member pointer to a GC object
    • The destructor must not call functions which are not annotated "safe for finalizers" TODO: how to annotate?
  • For any class inheriting from XPCOMGCObject or XPCOMGCFinalizedObject
    • raw members pointing to GC objects are not allowed... they must either be nsCOMPtr or they must be annotated indicating that they are a "safe" raw pointer. TODO: how to annotate?
  • For any class *not* inheriting from XPCOMGCObject or XPCOMGCFinalizedObject
    • the class must not contain nsCOMPtr member variables
    • the class may not contain member pointers to GC objects, unless those members are annotated "safe for GC marking" TODO: how to annotate?