mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-11 12:16:07 +00:00
ELF: Make error() to always set HasError.
Previously, it checked for the EC parameter and set HasError only when there was an error. But in most places we called error only when error had occurred, so this behavior was confusing. llvm-svn: 275517
This commit is contained in:
parent
615b85d9b4
commit
aa2db88984
@ -150,9 +150,10 @@ void LinkerDriver::addFile(StringRef Path) {
|
||||
|
||||
Optional<MemoryBufferRef> LinkerDriver::readFile(StringRef Path) {
|
||||
auto MBOrErr = MemoryBuffer::getFile(Path);
|
||||
error(MBOrErr, "cannot open " + Path);
|
||||
if (HasError)
|
||||
if (auto EC = MBOrErr.getError()) {
|
||||
error(EC, "cannot open " + Path);
|
||||
return None;
|
||||
}
|
||||
std::unique_ptr<MemoryBuffer> &MB = *MBOrErr;
|
||||
MemoryBufferRef MBRef = MB->getMemBufferRef();
|
||||
OwningMBs.push_back(std::move(MB)); // take MB ownership
|
||||
|
@ -40,8 +40,7 @@ void error(const Twine &Msg) {
|
||||
}
|
||||
|
||||
void error(std::error_code EC, const Twine &Prefix) {
|
||||
if (EC)
|
||||
error(Prefix + ": " + EC.message());
|
||||
error(Prefix + ": " + EC.message());
|
||||
}
|
||||
|
||||
void fatal(const Twine &Msg) {
|
||||
|
@ -1233,10 +1233,10 @@ template <class ELFT> void Writer<ELFT>::openFile() {
|
||||
ErrorOr<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
|
||||
FileOutputBuffer::create(Config->OutputFile, FileSize,
|
||||
FileOutputBuffer::F_executable);
|
||||
if (BufferOrErr)
|
||||
Buffer = std::move(*BufferOrErr);
|
||||
if (auto EC = BufferOrErr.getError())
|
||||
error(EC, "failed to open " + Config->OutputFile);
|
||||
else
|
||||
error(BufferOrErr, "failed to open " + Config->OutputFile);
|
||||
Buffer = std::move(*BufferOrErr);
|
||||
}
|
||||
|
||||
// Write section contents to a mmap'ed file.
|
||||
|
Loading…
x
Reference in New Issue
Block a user