YAML: Null terminate block scalar's value.

The commit null terminates the string value in the `yaml::BlockScalarNode`
class.

This change is motivated by the initial MIR serialization commit (r237708)
that I reverted in r237730 because the LLVM IR source from the block
scalar node wasn't terminated by a null character and thus the buildbots
failed on one testcase sometimes. This change enables me to recommit 
the reverted commit. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237942 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alex Lorenz
2015-05-21 19:45:02 +00:00
parent 7e452b8b73
commit 802ab073da
2 changed files with 14 additions and 1 deletions

View File

@ -2379,7 +2379,8 @@ parse_property:
, T.Range);
case Token::TK_BlockScalar: {
getNext();
StringRef StrCopy = StringRef(T.Value).copy(NodeAllocator);
StringRef NullTerminatedStr(T.Value.c_str(), T.Value.length() + 1);
StringRef StrCopy = NullTerminatedStr.copy(NodeAllocator).drop_back();
return new (NodeAllocator)
BlockScalarNode(stream.CurrentDoc, AnchorInfo.Range.substr(1),
TagInfo.Range, StrCopy, T.Range);