diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-11-18 15:50:04 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-11-18 15:50:04 +0000 |
commit | 6919bec07f9c4ee57a0e99f263b63546b386f22b (patch) | |
tree | fbcc184fdb7bc34d620d9a550965b38e717bbab5 /include/llvm | |
parent | 64409ad8e3b360b84349042f14b57f87a5c0ca18 (diff) | |
download | external_llvm-6919bec07f9c4ee57a0e99f263b63546b386f22b.zip external_llvm-6919bec07f9c4ee57a0e99f263b63546b386f22b.tar.gz external_llvm-6919bec07f9c4ee57a0e99f263b63546b386f22b.tar.bz2 |
Recover gracefully when deserializing invalid YAML input.
Fixes http://llvm.org/PR16221, http://llvm.org/PR15927
Phabricator: http://llvm-reviews.chandlerc.com/D1236
Patch by Andrew Tulloch!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195016 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Support/YAMLTraits.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index d6eeaac..8be5439 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -685,16 +685,18 @@ private: /// class Input : public IO { public: - // Construct a yaml Input object from a StringRef and optional user-data. - Input(StringRef InputContent, void *Ctxt=NULL); + // Construct a yaml Input object from a StringRef and optional + // user-data. The DiagHandler can be specified to provide + // alternative error reporting. + Input(StringRef InputContent, + void *Ctxt = NULL, + SourceMgr::DiagHandlerTy DiagHandler = NULL, + void *DiagHandlerCtxt = NULL); ~Input(); - + // Check if there was an syntax or semantic error during parsing. llvm::error_code error(); - // To set alternate error reporting. - void setDiagHandler(llvm::SourceMgr::DiagHandlerTy Handler, void *Ctxt = 0); - static bool classof(const IO *io) { return !io->outputting(); } private: @@ -968,8 +970,8 @@ template <typename T> inline typename llvm::enable_if_c<has_SequenceTraits<T>::value,Input &>::type operator>>(Input &yin, T &docSeq) { - yin.setCurrentDocument(); - yamlize(yin, docSeq, true); + if (yin.setCurrentDocument()) + yamlize(yin, docSeq, true); return yin; } |