Closed Bug 1632613 Opened 4 years ago Closed 4 years ago

Remove nsAutoPtr usage from dom/xslt/

Categories

(Core :: XSLT, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla77
Tracking Status
firefox77 --- fixed

People

(Reporter: erahm, Assigned: erahm)

References

Details

Attachments

(8 files)

This bug will track replacing usage of nsAutoPtr with UniquePtr in the xslt/ directory. See bug 1610067, comment 0 for more details.

nsAutoPtr is extensively used in xslt so it might make sense to take an iterative approach along the lines of:

  • Remove unnecessary includes
  • Convert anything that uses the copy ctor to use a move ctor, update any params that copy to use r-value instead
  • Convert anything that uses implicit conversion to use an explict get call
  • Swap over to UniquePtr
    • Replace declarations
    • Replace assignment with MakeUnique / WrapUnique
    • Replace forget with release
Depends on: 1632939

This adds a void** version fo getter_Transfers that is needed by the last remaining nsAutoPtr user in XSLT.

Assignee: nobody → erahm
Status: NEW → ASSIGNED

The first part of a larger conceptual change to switch XSLT over to UniquePtr. This part just replaces the nsAutoPtr includes.

This is essentially:

find dom/xslt -type f -n '*.h' | xargs sed -i -e 's/nsAutoPtr</mozilla::UniquePtr</g'
find dom/xslt -type f -n '*.cpp' | xargs sed -i -e 's/nsAutoPtr</UniquePtr</g'

UniquePtr uses a release method instead of forget.

UniquePtr doesn't provide access to the address of the raw pointer. This swaps out usage of StartAssignment to just point to the containers themselves.

UniquePtr doesn't allow assignment from raw pointers so we update callsites appropriately:

  • Assignment from new is mapped to MakeUnique
  • Assignment from pointer params or factory functions ware wrapped with WrapUnique
  • Assignment from release calls are switched to std::move

Additionally standalone release calls are piped into mozilla::Unused to stifle warnings and document that dropping the pointer is intentional.

Patches are up, this does more or less the bare minimum to convert over to UniquePtr. I broke up part 4 into conceptual changes to make it easier to review, particularly the search and replace parts. There could be some follow up to clean things up further, but is probably outside the scope of this bug. A few things I noted:

  • We could convert a bunch of release calls to moves, but that would require changing interfaces to take a UniquePtr as a param
  • The ownership model around txOwningArray is pretty odd and makes us jump through a few hoops
  • Factory functions such as txXPathNativeNode::createXPathNode could probably just return UniquePtr directly rather than having to be wrapped with WrapUnique
Pushed by erahm@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c7e617493865
Part 1: Add a void** version of UniquePtr getter_Transfers. r=KrisWright
https://hg.mozilla.org/integration/autoland/rev/d3bb0783c264
Part 2: Remove unused nsAutoPtr includes. r=peterv
https://hg.mozilla.org/integration/autoland/rev/9b8aa31b447d
Part 3: Convert implicit conversion to explicit. r=peterv
https://hg.mozilla.org/integration/autoland/rev/6665f5b6adb1
Part 4a: Swap out nsAutoPtr includes. r=peterv
https://hg.mozilla.org/integration/autoland/rev/73442956e2ba
Part 4b: Swap out nsAutoPtr type for UniquePtr. r=peterv
https://hg.mozilla.org/integration/autoland/rev/35ca121fe7ee
Part 4c: Swap out `forget` calls with `release`. r=peterv
https://hg.mozilla.org/integration/autoland/rev/bfbcc3e804f3
Part 4d: Replace `StartAssignment` usage. r=peterv
https://hg.mozilla.org/integration/autoland/rev/30cc2aa44812
Part 4e: Handle assignment to `UniquePtr` properly and silence warnings from `release` calls. r=peterv
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: