[Lldb-commits] [PATCH] Fix FileSpec::GetPath to return null-terminated strings

Zachary Turner zturner at google.com
Wed Feb 11 10:06:50 PST 2015


To be honest I would like to ban the use of raw cstring functions.  LLVM
has a wealth of classes to help with formatting strings, that I imagine
will cover 99% or more of use cases.  LLDB doesn't use them enough. I
consider these bugs in LLDB that should be fixed.  In cases where we really
do need a function for it, I think we should add it to LLVM, not to LLDB.
A quick summary of replacements is:

char stack_buffer[n];   // Use llvm::SmallString<n>
const char* foo;          // Use llvm::StringRef foo;
strcpy, strncpy, etc     // Use member functions of SmallString / StringRef
void foo(char *, int len);   // Use void foo(llvm::SmallVectorImpl<char>
&buf);
void foo(const char * foo);     // Use void foo(llvm::StringRef foo);
sprintf, snprintf, etc       // Use llvm::raw_ostream

On Wed Feb 11 2015 at 9:20:21 AM Vince Harron <vharron at google.com> wrote:

> Maybe Utility folder is better if all platforms have a conformant strncpy
> On Feb 11, 2015 9:19 AM, "Vince Harron" <vharron at google.com> wrote:
>
>> This might be overkill, but since we've seen this in more than one place,
>> it might make sense to add a Host function StrncpyTeminated that does this.
>> On Feb 11, 2015 7:28 AM, "Zachary Turner" <zturner at google.com> wrote:
>>
>>> Please wait to commit this until I've had a chance to review
>>> On Wed, Feb 11, 2015 at 4:05 AM Ilia K <ki.stfu at gmail.com> wrote:
>>>
>>>> @abidh,
>>>>
>>>> Take a look again please.
>>>>
>>>>
>>>> http://reviews.llvm.org/D7553
>>>>
>>>> EMAIL PREFERENCES
>>>>   http://reviews.llvm.org/settings/panel/emailpreferences/
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> 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/20150211/e2ac3d69/attachment.html>


More information about the lldb-commits mailing list