[PATCH] StringRef::copy should never copy empty strings

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 23 11:36:15 PDT 2016


Hi Mehdi, David

This is a spin off from the discussion on Allocator.h and requesting that we allocate 0 bytes.

Independent from whatever gets decided on Allocate behaviour, I think it would be best if StringRef::copy returns StringRef(nullptr, 0) whenever we try to copy an empty string.  StringRef(“”) would also be fine if you prefer.

This makes that change and adds test to the unit test for the new behavior.

Cheers,
Pete

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stringref.patch
Type: application/octet-stream
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160323/bf334e3e/attachment.obj>


More information about the llvm-commits mailing list