Index: include/llvm/Support/YAMLTraits.h =================================================================== --- include/llvm/Support/YAMLTraits.h +++ include/llvm/Support/YAMLTraits.h @@ -1418,8 +1418,8 @@ 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; } Index: test/Object/yaml2obj-invalid.yaml =================================================================== --- test/Object/yaml2obj-invalid.yaml +++ test/Object/yaml2obj-invalid.yaml @@ -0,0 +1,2 @@ +# RUN: not yaml2obj %s 2>&1 | FileCheck %s +# CHECK: Unknown document type!