diff options
author | Alex Bradbury <asb@lowrisc.org> | 2017-07-17 11:41:30 +0000 |
---|---|---|
committer | Alex Bradbury <asb@lowrisc.org> | 2017-07-17 11:41:30 +0000 |
commit | 1684317583f99316024a5e57d7377d8ad9087ffd (patch) | |
tree | d087e76bdf920838c178b8fe18fc1927306ba5f1 /llvm/lib/Support/YAMLTraits.cpp | |
parent | 11199b2ee5636b3d3bfd7029474fa7ae99460521 (diff) | |
download | bcm5719-llvm-1684317583f99316024a5e57d7377d8ad9087ffd.tar.gz bcm5719-llvm-1684317583f99316024a5e57d7377d8ad9087ffd.zip |
[YAMLTraits] Add filename support to yaml::Input
Summary:
The current yaml::Input constructor takes a StringRef of data as its
first parameter, discarding any filename information that may have been
present when a YAML file was opened. Add an alterate yaml::Input
constructor that takes a MemoryBufferRef, which can have a filename
associated with it. This leads to clearer diagnostic messages.
Sponsored By: DARPA, AFRL
Reviewed By: arphaman
Differential Revision: https://reviews.llvm.org/D35398
Patch by: Jonathan Anderson (trombonehero)
llvm-svn: 308172
Diffstat (limited to 'llvm/lib/Support/YAMLTraits.cpp')
-rw-r--r-- | llvm/lib/Support/YAMLTraits.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp index 601084f9eae..65eda246a7f 100644 --- a/llvm/lib/Support/YAMLTraits.cpp +++ b/llvm/lib/Support/YAMLTraits.cpp @@ -60,6 +60,14 @@ Input::Input(StringRef InputContent, void *Ctxt, DocIterator = Strm->begin(); } +Input::Input(MemoryBufferRef Input, void *Ctxt, + SourceMgr::DiagHandlerTy DiagHandler, void *DiagHandlerCtxt) + : IO(Ctxt), Strm(new Stream(Input, SrcMgr, false, &EC)) { + if (DiagHandler) + SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt); + DocIterator = Strm->begin(); +} + Input::~Input() = default; std::error_code Input::error() { return EC; } |