[llvm] r373923 - [Remarks] Pass StringBlockValue as StringRef.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 10:05:09 PDT 2019


Author: fhahn
Date: Mon Oct  7 10:05:09 2019
New Revision: 373923

URL: http://llvm.org/viewvc/llvm-project?rev=373923&view=rev
Log:
[Remarks] Pass StringBlockValue as StringRef.

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

Modified:
    llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp

Modified: llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp?rev=373923&r1=373922&r2=373923&view=diff
==============================================================================
--- llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp (original)
+++ llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp Mon Oct  7 10:05:09 2019
@@ -103,7 +103,7 @@ template <> struct MappingTraits<RemarkL
 /// newlines in strings.
 struct StringBlockVal {
   StringRef Value;
-  StringBlockVal(const std::string &Value) : Value(Value) {}
+  StringBlockVal(StringRef R) : Value(R) {}
 };
 
 template <> struct BlockScalarTraits<StringBlockVal> {




More information about the llvm-commits mailing list