Structs in our style system use an arena-style allocation system,
managed by the presshell to which they belong. All of the relevant
overloads that forward allocation requests to the presshell declare
themselves as CPP_THROW_NEW, which indicates that they do not throw
exceptions. The C++ specification states that operator new overloads
that declare themselves to not throw exceptions require a null check on
their return value. However, the relevant presshell allocation method,
AllocateByObjectID, is infallible and will never return a null pointer.
The callers of all of these methods are therefore doing useless
(compiler-generated) null checks. Let's get rid of those useless checks
by removing the CPP_THROW_NEW annotations. This change declares these
methods will return non-null pointers and throw exceptions in case of
errors--but as we don't use exceptions, and AllocateByObjectID will
abort on OOM, everything works out OK.
Structs in our style system use an arena-style allocation system,
managed by the presshell to which they belong. All of the relevant
overloads that forward allocation requests to the presshell declare
themselves as CPP_THROW_NEW, which indicates that they do not throw
exceptions. The C++ specification states that operator new overloads
that declare themselves to not throw exceptions require a null check on
their return value. However, the relevant presshell allocation method,
AllocateByObjectID, is infallible and will never return a null pointer.
The callers of all of these methods are therefore doing useless
(compiler-generated) null checks. Let's get rid of those useless checks
by removing the CPP_THROW_NEW annotations. This change declares these
methods will return non-null pointers and throw exceptions in case of
errors--but as we don't use exceptions, and AllocateByObjectID will
abort on OOM, everything works out OK.
The bulk of this commit was generated by running:
run-clang-tidy.py \
-checks='-*,llvm-namespace-comment' \
-header-filter=^/.../mozilla-central/.* \
-fix
"new nsFrameList()" becomes "new (shell) nsFrameList()".
"delete list" becomes "if (list) list->Delete(shell)" - note also that
an additional assertion was added that list is empty when deleted.
"nsAutoPtr<nsFrameList> list(StealSomeFrames())" becomes
"AutoFrameListPtr list(aPresContext, StealSomeFrames())"
* we know all types frames may be cast to at compile time, so instead of extensible GUID IIDs, use a big enum (see nsQueryFrame::FrameIID)
* eliminate all vestiges of refcounting, since frames aren't refcounted
Some frames (SVG frames in particular) still implement nsISupports-derived interfaces, for example nsISVGValue. There is a FrameIID for nsISVGValue that lets you go from a frame to the XPCOM interface, but you can't query back.
r+sr=roc
nsITextControlFrame didn't have an IID the first time around, but this wasn't a compile error because nsITextControlFrame::kFrameIID inherited from nsIFormControlFrame::kFrameIID. I've added a static analysis pass to verify the correct behavior, since I can't figure out a way to make the compiler do it.
--HG--
extra : rebase_source : 4894a2ca0278e2ab92f27459db77165f8348cf41