[llvm] r312177 - Simplify writeArchive return type.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 30 15:11:03 PDT 2017
Author: ruiu
Date: Wed Aug 30 15:11:03 2017
New Revision: 312177
URL: http://llvm.org/viewvc/llvm-project?rev=312177&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/Object/ArchiveWriter.h
llvm/trunk/lib/Object/ArchiveWriter.cpp
llvm/trunk/lib/Object/COFFImportFile.cpp
llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Modified: llvm/trunk/include/llvm/Object/ArchiveWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ArchiveWriter.h?rev=312177&r1=312176&r2=312177&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ArchiveWriter.h (original)
+++ llvm/trunk/include/llvm/Object/ArchiveWriter.h Wed Aug 30 15:11:03 2017
@@ -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);
Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=312177&r1=312176&r2=312177&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Wed Aug 30 15:11:03 2017
@@ -376,9 +376,8 @@ writeSymbolTable(raw_fd_ostream &Out, ob
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();
}
Modified: llvm/trunk/lib/Object/COFFImportFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFImportFile.cpp?rev=312177&r1=312176&r2=312177&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFImportFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFImportFile.cpp Wed Aug 30 15:11:03 2017
@@ -604,11 +604,9 @@ std::error_code writeImportLibrary(Strin
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
Modified: llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp?rev=312177&r1=312176&r2=312177&view=diff
==============================================================================
--- llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp (original)
+++ llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp Wed Aug 30 15:11:03 2017
@@ -153,15 +153,14 @@ int llvm::libDriverMain(llvm::ArrayRef<c
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;
}
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=312177&r1=312176&r2=312177&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Wed Aug 30 15:11:03 2017
@@ -688,10 +688,10 @@ performWriteOperation(ArchiveOperation O
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) {
More information about the llvm-commits
mailing list