[Lldb-commits] [lldb] r230046 - Add an OptionValueLanguage class

Vince Harron vharron at google.com
Mon Feb 23 14:16:56 PST 2015


Hi all,

We can't assume StringRef is null terminated, ever.

Vince
 On Feb 23, 2015 4:48 PM, "Joerg Sonnenberger" <joerg at britannica.bec.de>
wrote:

> On Mon, Feb 23, 2015 at 05:31:50PM +0000, Zachary Turner wrote:
> > How so? Suppose you've got a function which takes a const char*.
> Obviously
> > it's null terminated or your function wouldn't be able to work. If you
> > replace that with a StringRef it's still null terminated because the call
> > site hasn't changed. Either way, its up to the caller to pass something
> > null terminated.
> >
> > Any time you construct a StringRef from a std::string or ConstString,
> which
> > is very close to 100% of what we do, the StringRef is guaranteed to be
> null
> > terminated.
>
> But StringRef is normally a part of either a std::string or const char *.
> While there might be a null byte somewhere, it has no relation to the
> size of the string referenced by StringRef. The point is that accessing
> the data of a StringRef doesn't give a null terminated string of the
> same size as the StringRef, if at all.
>
> Joerg
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150223/fed58c4f/attachment.html>


More information about the lldb-commits mailing list