Hello,
I’ve attached a fairly large patch (touches 21 files).
The point of this patch is to remove all calls to std::vector::data() with &std::vector::front(). Apparently on CentOS 5 and Leopard, that method is not part of std::vector.
As a side note, should I be submitting these patches to this list or to lldb-commits?
Thanks!
foo.patch (14.8 KB)
Actually, I was thinking about this patch. There is probably going to be bad behavior when the vector is empty (and capacity is zero?). Please don’t apply this unless data() also has that problem.
Thanks,
Bill Lynch
It doesn't, or at least shouldn't. That's pretty much the point of data().
Sebastian
From the header documentation in the stl_vector.h from our C++ library on Mac OS X:
/**
* Returns a pointer such that [data(), data() + size()) is a valid
* range. For a non-empty %vector, data() == &front().
*/
pointer
data()
{ return pointer(this->_M_impl._M_start); }
So it does state "For a non-empty %vector, data() == &front().", so I would avoid this patch for now.
std::vector::data() isn't part of C++'98. I'd recommend using llvm::SmallVector or using &V[0] with a check that V isn't empty.
-Chris
Yep, after I saw the header comment, I thought the same thing and I am about to commit a patch to get rid of using it.
Modified version of this patch was submitted with r108957.
Thanks for catching this William.
Greg Clayton
Thank you for fixing it up!
Since we’re on the subject of missing standard library methods, I figured now would be a good time to bring up this patch as well. I don’t have a std::bitset::to_string() on Leopard either.
The implementation was pulled from http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/bitset?view=markup
-Bill
Index: source/Core/DataExtractor.cpp
Committed revision 108976.
Thanks!