2012-06-01 06:34:00 +08:00
|
|
|
//===- lib/ReaderWriter/Reader.cpp ----------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lld/ReaderWriter/Reader.h"
|
|
|
|
|
|
|
|
#include "llvm/ADT/OwningPtr.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
#include "llvm/Support/system_error.h"
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
Reader::~Reader() {
|
|
|
|
}
|
|
|
|
|
|
|
|
error_code Reader::readFile(StringRef path,
|
2013-01-23 09:18:43 +08:00
|
|
|
std::vector<std::unique_ptr<File>> &result) {
|
2012-06-01 06:34:00 +08:00
|
|
|
OwningPtr<llvm::MemoryBuffer> opmb;
|
2013-01-23 09:18:43 +08:00
|
|
|
if (error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, opmb))
|
2012-06-01 06:34:00 +08:00
|
|
|
return ec;
|
|
|
|
|
|
|
|
std::unique_ptr<MemoryBuffer> mb(opmb.take());
|
|
|
|
return this->parseFile(std::move(mb), result);
|
|
|
|
}
|
2013-01-23 09:18:43 +08:00
|
|
|
} // end namespace lld
|