[lld] f309183 - [lld] Use checkError more
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 4 08:48:31 PDT 2021
Author: Nico Weber
Date: 2021-10-04T11:46:16-04:00
New Revision: f3091831f444328cc1a987d5754438143fa869b3
URL: https://github.com/llvm/llvm-project/commit/f3091831f444328cc1a987d5754438143fa869b3
DIFF: https://github.com/llvm/llvm-project/commit/f3091831f444328cc1a987d5754438143fa869b3.diff
LOG: [lld] Use checkError more
No behavior change.
Added:
Modified:
lld/COFF/Driver.cpp
lld/ELF/Driver.cpp
lld/MachO/Driver.cpp
Removed:
################################################################################
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 9ebd1c336c594..a4681e4ca661d 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -823,16 +823,12 @@ static void createImportLibrary(bool asLib) {
exports.push_back(e2);
}
- auto handleError = [](Error &&e) {
- handleAllErrors(std::move(e),
- [](ErrorInfoBase &eib) { error(eib.message()); });
- };
std::string libName = getImportName(asLib);
std::string path = getImplibPath();
if (!config->incremental) {
- handleError(writeImportLibrary(libName, path, exports, config->machine,
- config->mingw));
+ checkError(writeImportLibrary(libName, path, exports, config->machine,
+ config->mingw));
return;
}
@@ -841,8 +837,8 @@ static void createImportLibrary(bool asLib) {
ErrorOr<std::unique_ptr<MemoryBuffer>> oldBuf = MemoryBuffer::getFile(
path, /*IsText=*/false, /*RequiresNullTerminator=*/false);
if (!oldBuf) {
- handleError(writeImportLibrary(libName, path, exports, config->machine,
- config->mingw));
+ checkError(writeImportLibrary(libName, path, exports, config->machine,
+ config->mingw));
return;
}
@@ -854,7 +850,7 @@ static void createImportLibrary(bool asLib) {
if (Error e = writeImportLibrary(libName, tmpName, exports, config->machine,
config->mingw)) {
- handleError(std::move(e));
+ checkError(std::move(e));
return;
}
@@ -862,7 +858,7 @@ static void createImportLibrary(bool asLib) {
tmpName, /*IsText=*/false, /*RequiresNullTerminator=*/false));
if ((*oldBuf)->getBuffer() != newBuf->getBuffer()) {
oldBuf->reset();
- handleError(errorCodeToError(sys::fs::rename(tmpName, path)));
+ checkError(errorCodeToError(sys::fs::rename(tmpName, path)));
} else {
sys::fs::remove(tmpName);
}
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 8cb81987163fc..1b9154a190624 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -573,14 +573,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
}
if (config->timeTraceEnabled) {
- if (auto E = timeTraceProfilerWrite(args.getLastArgValue(OPT_time_trace_file_eq).str(),
- config->outputFile)) {
- handleAllErrors(std::move(E), [&](const StringError &SE) {
- error(SE.getMessage());
- });
- return;
- }
-
+ checkError(timeTraceProfilerWrite(
+ args.getLastArgValue(OPT_time_trace_file_eq).str(),
+ config->outputFile));
timeTraceProfilerCleanup();
}
}
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 449eb745aeb5d..0611f556fa526 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1436,12 +1436,9 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
}
if (config->timeTraceEnabled) {
- if (auto E = timeTraceProfilerWrite(
- args.getLastArgValue(OPT_time_trace_file_eq).str(),
- config->outputFile)) {
- handleAllErrors(std::move(E),
- [&](const StringError &SE) { error(SE.getMessage()); });
- }
+ checkError(timeTraceProfilerWrite(
+ args.getLastArgValue(OPT_time_trace_file_eq).str(),
+ config->outputFile));
timeTraceProfilerCleanup();
}
More information about the llvm-commits
mailing list