StringRef::copy shouldn't allocate anything for length 0 strings.
authorPete Cooper <peter_cooper@apple.com>
Wed, 23 Mar 2016 21:49:31 +0000 (21:49 +0000)
committerPete Cooper <peter_cooper@apple.com>
Wed, 23 Mar 2016 21:49:31 +0000 (21:49 +0000)
commitb08d9060b77ee35d278397dfca54a72a86c3a9bb
tree6004f37b8f47d10989b721e7ff9078aa0b98463b
parentf43c2a0b4967626c7255940a7317ec4c8c9e9319
StringRef::copy shouldn't allocate anything for length 0 strings.

The BumpPtrAllocator currently doesn't handle zero length allocations well.
The discussion for how to fix that is ongoing.  However, there's no need
for StringRef::copy to actually allocate anything here anyway, so just
return StringRef() when we get a zero length copy.

Reviewed by David Blaikie

llvm-svn: 264201
llvm/include/llvm/ADT/StringRef.h
llvm/unittests/ADT/StringRefTest.cpp