diff --git a/llvm/lib/Remarks/YAMLRemarkParser.cpp b/llvm/lib/Remarks/YAMLRemarkParser.cpp --- a/llvm/lib/Remarks/YAMLRemarkParser.cpp +++ b/llvm/lib/Remarks/YAMLRemarkParser.cpp @@ -293,9 +293,16 @@ Expected YAMLRemarkParser::parseStr(yaml::KeyValueNode &Node) { auto *Value = dyn_cast(Node.getValue()); - if (!Value) - return error("expected a value of scalar type.", Node); - StringRef Result = Value->getRawValue(); + yaml::BlockScalarNode *ValueBlock; + StringRef Result; + if (!Value) { + // Try to parse the value as a block node. + ValueBlock = dyn_cast(Node.getValue()); + if (!ValueBlock) + return error("expected a value of scalar type.", Node); + Result = ValueBlock->getValue(); + } else + Result = Value->getRawValue(); if (Result.front() == '\'') Result = Result.drop_front(); @@ -429,9 +436,16 @@ Expected YAMLStrTabRemarkParser::parseStr(yaml::KeyValueNode &Node) { auto *Value = dyn_cast(Node.getValue()); - if (!Value) - return error("expected a value of scalar type.", Node); + yaml::BlockScalarNode *ValueBlock; StringRef Result; + if (!Value) { + // Try to parse the value as a block node. + ValueBlock = dyn_cast(Node.getValue()); + if (!ValueBlock) + return error("expected a value of scalar type.", Node); + Result = ValueBlock->getValue(); + } else + Result = Value->getRawValue(); // If we have a string table, parse it as an unsigned. unsigned StrID = 0; if (Expected MaybeStrID = parseUnsigned(Node)) diff --git a/llvm/unittests/Remarks/YAMLRemarksParsingTest.cpp b/llvm/unittests/Remarks/YAMLRemarksParsingTest.cpp --- a/llvm/unittests/Remarks/YAMLRemarksParsingTest.cpp +++ b/llvm/unittests/Remarks/YAMLRemarksParsingTest.cpp @@ -154,6 +154,16 @@ " - String: ' because its definition is unavailable'\n" "Pass: inline\n" ""); + + // Block Remark. + parseGood("\n" + "--- !Missed\n" + "Function: foo\n" + "Name: NoDefinition\n" + "Args:\n" + " - String: |\n \n \n blocks\n" + "Pass: inline\n" + ""); } // Mandatory common part of a remark.