mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-04 14:22:26 +00:00
Simplify writeArchive return type.
writeArchive returned a pair, but the first element of the pair is always its first argument on failure, so it doesn't make sense to return it from the function. This patch change the return type so that it does't return it. Differential Revision: https://reviews.llvm.org/D37313 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312177 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
564f4d8415
commit
aa892fdd03
@ -37,7 +37,7 @@ struct NewArchiveMember {
|
||||
bool Deterministic);
|
||||
};
|
||||
|
||||
std::pair<StringRef, std::error_code>
|
||||
std::error_code
|
||||
writeArchive(StringRef ArcName, std::vector<NewArchiveMember> &NewMembers,
|
||||
bool WriteSymtab, object::Archive::Kind Kind, bool Deterministic,
|
||||
bool Thin, std::unique_ptr<MemoryBuffer> OldArchiveBuf = nullptr);
|
||||
|
@ -376,9 +376,8 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind,
|
||||
return BodyStartOffset + 4;
|
||||
}
|
||||
|
||||
std::pair<StringRef, std::error_code>
|
||||
llvm::writeArchive(StringRef ArcName,
|
||||
std::vector<NewArchiveMember> &NewMembers,
|
||||
std::error_code
|
||||
llvm::writeArchive(StringRef ArcName, std::vector<NewArchiveMember> &NewMembers,
|
||||
bool WriteSymtab, object::Archive::Kind Kind,
|
||||
bool Deterministic, bool Thin,
|
||||
std::unique_ptr<MemoryBuffer> OldArchiveBuf) {
|
||||
@ -387,7 +386,7 @@ llvm::writeArchive(StringRef ArcName,
|
||||
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 @@ llvm::writeArchive(StringRef ArcName,
|
||||
ErrorOr<unsigned> 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 @@ llvm::writeArchive(StringRef ArcName,
|
||||
OldArchiveBuf.reset();
|
||||
|
||||
sys::fs::rename(TmpArchive, ArcName);
|
||||
return std::make_pair("", std::error_code());
|
||||
return std::error_code();
|
||||
}
|
||||
|
@ -604,11 +604,9 @@ std::error_code writeImportLibrary(StringRef ImportName, StringRef Path,
|
||||
OF.createShortImport(*Name, E.Ordinal, ImportType, NameType));
|
||||
}
|
||||
|
||||
std::pair<StringRef, std::error_code> 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
|
||||
|
@ -153,15 +153,14 @@ int llvm::libDriverMain(llvm::ArrayRef<const char*> ArgsArr) {
|
||||
Members.emplace_back(std::move(*MOrErr));
|
||||
}
|
||||
|
||||
std::pair<StringRef, std::error_code> 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;
|
||||
}
|
||||
|
||||
|
@ -688,10 +688,10 @@ performWriteOperation(ArchiveOperation Operation,
|
||||
break;
|
||||
}
|
||||
|
||||
std::pair<StringRef, std::error_code> 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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user