Return a std::unique_ptr from the IRReader.h functions. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216466 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-08-26 17:29:46 +00:00
parent 1bfd87a150
commit 81e49922a8
10 changed files with 51 additions and 55 deletions

View File

@@ -55,17 +55,16 @@ static cl::opt<bool>
SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"),
cl::init(false));
// LoadFile - Read the specified bitcode file in and return it. This routine
// searches the link path for the specified file to try to find it...
// Read the specified bitcode file in and return it. This routine searches the
// link path for the specified file to try to find it...
//
static inline Module *LoadFile(const char *argv0, const std::string &FN,
LLVMContext& Context) {
static std::unique_ptr<Module>
loadFile(const char *argv0, const std::string &FN, LLVMContext &Context) {
SMDiagnostic Err;
if (Verbose) errs() << "Loading '" << FN << "'\n";
Module* Result = nullptr;
Result = ParseIRFile(FN, Err, Context);
if (Result) return Result; // Load successful!
std::unique_ptr<Module> Result = parseIRFile(FN, Err, Context);
if (Result)
return Result;
Err.print(argv0, errs());
return nullptr;
@@ -83,8 +82,8 @@ int main(int argc, char **argv) {
unsigned BaseArg = 0;
std::string ErrorMessage;
std::unique_ptr<Module> Composite(
LoadFile(argv[0], InputFilenames[BaseArg], Context));
std::unique_ptr<Module> Composite =
loadFile(argv[0], InputFilenames[BaseArg], Context);
if (!Composite.get()) {
errs() << argv[0] << ": error loading file '"
<< InputFilenames[BaseArg] << "'\n";
@@ -93,7 +92,7 @@ int main(int argc, char **argv) {
Linker L(Composite.get(), SuppressWarnings);
for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
std::unique_ptr<Module> M(LoadFile(argv[0], InputFilenames[i], Context));
std::unique_ptr<Module> M = loadFile(argv[0], InputFilenames[i], Context);
if (!M.get()) {
errs() << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n";
return 1;