[PATCH] D25257: Use StringRef in Option library instead of raw pointers (NFC)

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 16:51:29 PDT 2016


zturner added a comment.

In https://reviews.llvm.org/D25257#565088, @mehdi_amini wrote:

> I'm not aware of any ownership issue here, so I don’t know what you’re referring to?


The ownership problem I'm referring to is that if you return a `str.str().c_str()`, the resulting `c_str()` will die immediately, whereas the caller might need the pointer to remain alive.  A `StringSaver` would solve that, so that you could return `Saver.save(str).data()` anywhere you would normally want to return `str.data()`


https://reviews.llvm.org/D25257





More information about the llvm-commits mailing list