This is an archive of the discontinued LLVM Phabricator instance.

ADT: Add OwningArrayRef class.
ClosedPublic

Authored by pcc on Dec 13 2016, 11:21 AM.

Details

Summary

This is a MutableArrayRef that owns its array.
I plan to use this in D22296.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 81262.Dec 13 2016, 11:21 AM
pcc retitled this revision from to ADT: Add OwningArrayRef class..
pcc updated this object.
pcc added a reviewer: rjmccall.
pcc added a subscriber: llvm-commits.
rjmccall edited edge metadata.Dec 13 2016, 11:40 AM

LGTM. Things like this ArrayRef constructor really make me wish that C++ had labelled arguments, though.

This revision was automatically updated to reflect the committed changes.
Eugene.Zelenko added inline comments.
llvm/trunk/include/llvm/ADT/ArrayRef.h
419

Please use = default;

rsmith added a subscriber: rsmith.Dec 20 2016, 4:03 PM

This doesn't make any sense to me at all. The whole point of ArrayRef is as a non-owning handle to an externally-owned array. Why would someone use this rather than, say, vector or SmallVector? (The only real difference I can see compared to vector is that you save one pointer by not allowing the size and capacity to differ, at the cost of tying together allocation and initialization.)

If this genuinely is useful, please update http://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-for-a-task to explain when this container should be used.