[Lldb-commits] [lldb] r179779 - Since we use C++11, we should switch over to using std::unique_ptr when C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++.

Chris Lattner clattner at apple.com
Thu Apr 18 15:17:57 PDT 2013


On Apr 18, 2013, at 3:13 PM, Greg Clayton <gclayton at apple.com> wrote:
>>> Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro.
>> 
>> Why use a macro here?  lldb already requires C++'11 support, so why not just use unique_ptr unconditionally?
> 
> 
> We should really get rid of all these macros then. Still, since C++11 is enabled, it will always use std::unique_ptr. We had a ton of std::auto_ptr stuff laying around and I wanted to fix that.
> 
> It might be nice to still have the macros in case somebody wants to use a different C++ library in the future? Though theoretically any new shared library should have std::shared_ptr/weak_ptr/unique_ptr. 
> 
> The current macros would let us substitute in another debug version of these classes in case we wanted to debug these pointers.

Please don't do this.  Please look forward, not back.  C++'11 is the future, and there is no reason to add an abstraction over this.  Just write to portable C++'11 code without unnecessary abstractions.

Further, if this abstraction were actually useful, it should be sunk down into llvm, not doing specifically in LLDB.

-Chris



More information about the lldb-commits mailing list