aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Remarks/YAMLRemarkParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Remarks/YAMLRemarkParser.cpp')
-rw-r--r--llvm/lib/Remarks/YAMLRemarkParser.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/lib/Remarks/YAMLRemarkParser.cpp b/llvm/lib/Remarks/YAMLRemarkParser.cpp
index 4996ab6b08b9..f5123b0f64ce 100644
--- a/llvm/lib/Remarks/YAMLRemarkParser.cpp
+++ b/llvm/lib/Remarks/YAMLRemarkParser.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "YAMLRemarkParser.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Path.h"
@@ -292,9 +293,16 @@ Expected<StringRef> YAMLRemarkParser::parseKey(yaml::KeyValueNode &Node) {
Expected<StringRef> YAMLRemarkParser::parseStr(yaml::KeyValueNode &Node) {
auto *Value = dyn_cast<yaml::ScalarNode>(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<yaml::BlockScalarNode>(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();
@@ -428,9 +436,16 @@ Expected<std::unique_ptr<Remark>> YAMLRemarkParser::next() {
Expected<StringRef> YAMLStrTabRemarkParser::parseStr(yaml::KeyValueNode &Node) {
auto *Value = dyn_cast<yaml::ScalarNode>(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<yaml::BlockScalarNode>(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<unsigned> MaybeStrID = parseUnsigned(Node))