Index: lld/trunk/COFF/Driver.cpp =================================================================== --- lld/trunk/COFF/Driver.cpp +++ lld/trunk/COFF/Driver.cpp @@ -581,12 +581,12 @@ std::string Temp = S.str(); TemporaryFiles.push_back(Temp); - std::pair Ret = + std::error_code EC = llvm::writeArchive(Temp, New, /*WriteSymtab=*/true, Archive::Kind::K_GNU, /*Deterministics=*/true, /*Thin=*/false); - if (Ret.second) - error("failed to create a new archive " + S.str() + ": " + Ret.first); + if (EC) + error("failed to create a new archive " + S.str() + ": " + EC.message()); return Temp; } Index: llvm/trunk/include/llvm/Object/ArchiveWriter.h =================================================================== --- llvm/trunk/include/llvm/Object/ArchiveWriter.h +++ llvm/trunk/include/llvm/Object/ArchiveWriter.h @@ -37,7 +37,7 @@ bool Deterministic); }; -std::pair +std::error_code writeArchive(StringRef ArcName, std::vector &NewMembers, bool WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr OldArchiveBuf = nullptr); Index: llvm/trunk/lib/Object/ArchiveWriter.cpp =================================================================== --- llvm/trunk/lib/Object/ArchiveWriter.cpp +++ llvm/trunk/lib/Object/ArchiveWriter.cpp @@ -376,9 +376,8 @@ return BodyStartOffset + 4; } -std::pair -llvm::writeArchive(StringRef ArcName, - std::vector &NewMembers, +std::error_code +llvm::writeArchive(StringRef ArcName, std::vector &NewMembers, bool WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr OldArchiveBuf) { @@ -387,7 +386,7 @@ int TmpArchiveFD; if (auto EC = sys::fs::createUniqueFile(ArcName + ".temp-archive-%%%%%%%.a", TmpArchiveFD, TmpArchive)) - return std::make_pair(ArcName, EC); + return EC; tool_output_file Output(TmpArchive, TmpArchiveFD); raw_fd_ostream &Out = Output.os(); @@ -403,7 +402,7 @@ ErrorOr MemberReferenceOffsetOrErr = writeSymbolTable( Out, Kind, NewMembers, MemberOffsetRefs, Deterministic); if (auto EC = MemberReferenceOffsetOrErr.getError()) - return std::make_pair(ArcName, EC); + return EC; MemberReferenceOffset = MemberReferenceOffsetOrErr.get(); } @@ -465,5 +464,5 @@ OldArchiveBuf.reset(); sys::fs::rename(TmpArchive, ArcName); - return std::make_pair("", std::error_code()); + return std::error_code(); } Index: llvm/trunk/lib/Object/COFFImportFile.cpp =================================================================== --- llvm/trunk/lib/Object/COFFImportFile.cpp +++ llvm/trunk/lib/Object/COFFImportFile.cpp @@ -604,11 +604,9 @@ OF.createShortImport(*Name, E.Ordinal, ImportType, NameType)); } - std::pair Result = - writeArchive(Path, Members, /*WriteSymtab*/ true, object::Archive::K_GNU, - /*Deterministic*/ true, /*Thin*/ false); - - return Result.second; + return writeArchive(Path, Members, /*WriteSymtab*/ true, + object::Archive::K_GNU, + /*Deterministic*/ true, /*Thin*/ false); } } // namespace object Index: llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp =================================================================== --- llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -153,15 +153,14 @@ Members.emplace_back(std::move(*MOrErr)); } - std::pair Result = - llvm::writeArchive(getOutputPath(&Args, Members[0]), Members, + std::string OutputPath = getOutputPath(&Args, Members[0]); + std::error_code EC = + llvm::writeArchive(OutputPath, Members, /*WriteSymtab=*/true, object::Archive::K_GNU, /*Deterministic*/ true, Args.hasArg(OPT_llvmlibthin)); - if (Result.second) { - if (Result.first.empty()) - Result.first = ArgsArr[0]; - llvm::errs() << Result.first << ": " << Result.second.message() << "\n"; + if (EC) { + llvm::errs() << OutputPath << ": " << EC.message() << "\n"; return 1; } Index: llvm/trunk/tools/llvm-ar/llvm-ar.cpp =================================================================== --- llvm/trunk/tools/llvm-ar/llvm-ar.cpp +++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp @@ -688,10 +688,10 @@ break; } - std::pair Result = + std::error_code EC = writeArchive(ArchiveName, NewMembersP ? *NewMembersP : NewMembers, Symtab, Kind, Deterministic, Thin, std::move(OldArchiveBuf)); - failIfError(Result.second, Result.first); + failIfError(EC, ArchiveName); } static void createSymbolTable(object::Archive *OldArchive) {