[yaml2obj] - Don't crash on invalid document.

Previously jaml2obj would segfault on empty document.
(without yaml description).
Patch fixes the issue.

Differential revision: https://reviews.llvm.org/D38036

llvm-svn: 313746
This commit is contained in:
George Rimar 2017-09-20 09:57:11 +00:00
parent b0f0a1ea03
commit cefe7e1142
2 changed files with 4 additions and 2 deletions

View File

@ -1418,8 +1418,8 @@ inline typename std::enable_if<has_MappingTraits<T, EmptyContext>::value,
Input &>::type Input &>::type
operator>>(Input &yin, T &docMap) { operator>>(Input &yin, T &docMap) {
EmptyContext Ctx; EmptyContext Ctx;
yin.setCurrentDocument(); if (yin.setCurrentDocument())
yamlize(yin, docMap, true, Ctx); yamlize(yin, docMap, true, Ctx);
return yin; return yin;
} }

View File

@ -0,0 +1,2 @@
# RUN: not yaml2obj %s 2>&1 | FileCheck %s
# CHECK: Unknown document type!