summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Driver.cpp4
-rw-r--r--lld/ELF/Error.cpp16
-rw-r--r--lld/ELF/Error.h8
-rw-r--r--lld/ELF/Writer.cpp4
4 files changed, 16 insertions, 16 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index b95795e031e..b22407d8a66 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -92,8 +92,10 @@ void LinkerDriver::addFile(StringRef Path) {
using namespace llvm::sys::fs;
log(Path);
auto MBOrErr = MemoryBuffer::getFile(Path);
- if (error(MBOrErr, "cannot open " + Path))
+ if (!MBOrErr) {
+ error(MBOrErr, "cannot open " + Path);
return;
+ }
std::unique_ptr<MemoryBuffer> &MB = *MBOrErr;
MemoryBufferRef MBRef = MB->getMemBufferRef();
OwningMBs.push_back(std::move(MB)); // take MB ownership
diff --git a/lld/ELF/Error.cpp b/lld/ELF/Error.cpp
index 9e42910915a..beda4af658c 100644
--- a/lld/ELF/Error.cpp
+++ b/lld/ELF/Error.cpp
@@ -31,18 +31,14 @@ void error(const Twine &Msg) {
HasError = true;
}
-bool error(std::error_code EC, const Twine &Prefix) {
- if (!EC)
- return false;
- error(Prefix + ": " + EC.message());
- return true;
+void error(std::error_code EC, const Twine &Prefix) {
+ if (EC)
+ error(Prefix + ": " + EC.message());
}
-bool error(std::error_code EC) {
- if (!EC)
- return false;
- error(EC.message());
- return true;
+void error(std::error_code EC) {
+ if (EC)
+ error(EC.message());
}
void fatal(const Twine &Msg) {
diff --git a/lld/ELF/Error.h b/lld/ELF/Error.h
index cf3bd897781..05a3e0a56a9 100644
--- a/lld/ELF/Error.h
+++ b/lld/ELF/Error.h
@@ -22,14 +22,14 @@ void log(const Twine &Msg);
void warning(const Twine &Msg);
void error(const Twine &Msg);
-bool error(std::error_code EC, const Twine &Prefix);
-bool error(std::error_code EC);
+void error(std::error_code EC, const Twine &Prefix);
+void error(std::error_code EC);
-template <typename T> bool error(const ErrorOr<T> &V, const Twine &Prefix) {
+template <typename T> void error(const ErrorOr<T> &V, const Twine &Prefix) {
return error(V.getError(), Prefix);
}
-template <typename T> bool error(const ErrorOr<T> &V) {
+template <typename T> void error(const ErrorOr<T> &V) {
return error(V.getError());
}
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 4887c666fae..7ccd68db7c1 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1534,8 +1534,10 @@ template <class ELFT> bool Writer<ELFT>::openFile() {
ErrorOr<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
FileOutputBuffer::create(Config->OutputFile, FileSize,
FileOutputBuffer::F_executable);
- if (error(BufferOrErr, "failed to open " + Config->OutputFile))
+ if (!BufferOrErr) {
+ error(BufferOrErr, "failed to open " + Config->OutputFile);
return false;
+ }
Buffer = std::move(*BufferOrErr);
return true;
}
OpenPOWER on IntegriCloud