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
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) {
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());
}
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;
}