summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Support/YAMLTraits.h4
-rw-r--r--llvm/test/Object/yaml2obj-invalid.yaml2
2 files changed, 4 insertions, 2 deletions
diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index 71fdf47f197..5f6f0493e28 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -1418,8 +1418,8 @@ inline typename std::enable_if<has_MappingTraits<T, EmptyContext>::value,
Input &>::type
operator>>(Input &yin, T &docMap) {
EmptyContext Ctx;
- yin.setCurrentDocument();
- yamlize(yin, docMap, true, Ctx);
+ if (yin.setCurrentDocument())
+ yamlize(yin, docMap, true, Ctx);
return yin;
}
diff --git a/llvm/test/Object/yaml2obj-invalid.yaml b/llvm/test/Object/yaml2obj-invalid.yaml
new file mode 100644
index 00000000000..d1f4fa26d82
--- /dev/null
+++ b/llvm/test/Object/yaml2obj-invalid.yaml
@@ -0,0 +1,2 @@
+# RUN: not yaml2obj %s 2>&1 | FileCheck %s
+# CHECK: Unknown document type!
OpenPOWER on IntegriCloud