Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 1 | //===- lib/ReaderWriter/Reader.cpp ----------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Linker |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lld/ReaderWriter/Reader.h" |
| 11 | |
| 12 | #include "llvm/ADT/OwningPtr.h" |
| 13 | #include "llvm/ADT/StringRef.h" |
| 14 | #include "llvm/Support/MemoryBuffer.h" |
| 15 | #include "llvm/Support/system_error.h" |
| 16 | |
Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 17 | namespace lld { |
Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 18 | Reader::~Reader() { |
| 19 | } |
| 20 | |
| 21 | error_code Reader::readFile(StringRef path, |
Nick Kledzik | c314b46 | 2013-04-04 18:59:24 +0000 | [diff] [blame] | 22 | std::vector<std::unique_ptr<File>> &result) const { |
Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 23 | OwningPtr<llvm::MemoryBuffer> opmb; |
Michael J. Spencer | 64afcb4 | 2013-01-23 01:18:43 +0000 | [diff] [blame] | 24 | if (error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, opmb)) |
Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 25 | return ec; |
Shankar Easwaran | 8962feb | 2013-03-14 16:09:49 +0000 | [diff] [blame] | 26 | |
Michael J. Spencer | e6d5609 | 2013-04-05 22:04:44 +0000 | [diff] [blame^] | 27 | std::unique_ptr<MemoryBuffer> mb(opmb.take()); |
| 28 | return this->parseFile(mb, result); |
Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 29 | } |
Shankar Easwaran | 8962feb | 2013-03-14 16:09:49 +0000 | [diff] [blame] | 30 | } // end namespace lld |