diff options
Diffstat (limited to 'llvm/lib/Remarks/YAMLRemarkSerializer.cpp')
-rw-r--r-- | llvm/lib/Remarks/YAMLRemarkSerializer.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Remarks/YAMLRemarkSerializer.cpp b/llvm/lib/Remarks/YAMLRemarkSerializer.cpp index 42ebfbf..22e2970 100644 --- a/llvm/lib/Remarks/YAMLRemarkSerializer.cpp +++ b/llvm/lib/Remarks/YAMLRemarkSerializer.cpp @@ -114,15 +114,13 @@ template <> struct MappingTraits<Argument> { static void mapping(IO &io, Argument &A) { assert(io.outputting() && "input not yet implemented"); - // A.Key.data() is not necessarily null-terminated, so we must make a copy, - // otherwise we potentially read out of bounds. - // FIXME: Add support for StringRef Keys in YAML IO. - std::string Key(A.Key); + // NB: A.Key.data() is not necessarily null-terminated, as the StringRef may + // be a span into the middle of a string. if (StringRef(A.Val).count('\n') > 1) { StringBlockVal S(A.Val); - io.mapRequired(Key.c_str(), S); + io.mapRequired(A.Key, S); } else { - io.mapRequired(Key.c_str(), A.Val); + io.mapRequired(A.Key, A.Val); } io.mapOptional("DebugLoc", A.Loc); } |