[Remarks] Pass StringBlockValue as StringRef.
authorFlorian Hahn <flo@fhahn.com>
Mon, 7 Oct 2019 17:05:09 +0000 (17:05 +0000)
committerFlorian Hahn <flo@fhahn.com>
Mon, 7 Oct 2019 17:05:09 +0000 (17:05 +0000)
After changing the remark serialization, we now pass StringRefs to the
serializer. We should use StringRef for StringBlockVal, to avoid
creating temporary objects, which then cause StringBlockVal.Value to
point to invalid memory.

Reviewers: thegameg, anemet

Reviewed By: thegameg

Differential Revision: https://reviews.llvm.org/D68571

llvm-svn: 373923

llvm/lib/Remarks/YAMLRemarkSerializer.cpp

index 66eb06b..3a42fe0 100644 (file)
@@ -103,7 +103,7 @@ template <> struct MappingTraits<RemarkLocation> {
 /// newlines in strings.
 struct StringBlockVal {
   StringRef Value;
-  StringBlockVal(const std::string &Value) : Value(Value) {}
+  StringBlockVal(StringRef R) : Value(R) {}
 };
 
 template <> struct BlockScalarTraits<StringBlockVal> {