[lldb-dev] std::shared_ptr, RTTI, and LLDB
gclayton at apple.com
Thu Jun 10 18:06:17 PDT 2010
On Jun 10, 2010, at 5:56 PM, Howard Hinnant wrote:
> Greg Clayton wrote:
>> We use a lot of shared pointers, though we aren't currently using the fancy RTTI aspects of it. We really want _some_ sort of shared pointer so we can have STL collections of objects that don't move around when collections grow. Also with a lot of our partial parsing we can determine how many objects there are in a collection, resize the collection to contain that many objects, then lazily populate such objects.
>> As long as it is a reference counted pointer that doesn't require us to build boost.
>> We can easily replace all shared pointers within LLDB by redefining "lldb::SharedPtr" in lldb-types.h.
>> Feel free to experiment, though I would rather not pull in all of boost just to get a shared pointer... We currently get that from a tr1 directory on MacOSX. Does linux have a similar implementation in tr1 (#include <tr1/memory>)? We do make use of putting objects into shared pointers that are the virtual base class impementations of pure virtual protocols, so I am not sure if this requires RTTI (I can't remember what role RTTI plays in the shared pointers...).
> libc++ (http://libcxx.llvm.org/) has a std::shared_ptr:
> If desired I can pull the shared_ptr bits out of this file, reduce dependencies as much as possible, pull the rtti bits, and ship you a custom shared_ptr.
> I should first peruse your source and find out just how much shared_ptr you need. For example if you don't need weak_ptr or enable_shared_from_this, I can trim shared_ptr from two reference counts down to one. This trimming is already done in libc++ as I needed it for locale anyway.
Howard, that would be great if you could trim this down for us.
I don't believe we need anyting fancy (no RTTI, no weak_ptr (what I am aware of), no enable_shard_from_this). If you can send me a header that we can include into our Utility folder, I will check it in ASAP and see if we switch over to using it.
My goal is to get us off of RTTI in LLDB so we can start intermixing LLVM all over the place without any RTTI woes.
More information about the lldb-dev