From 7b8b9ae1cb4e42324ca57b9805aea96c57cdb7b6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 11 Jun 2014 19:05:58 +0000 Subject: [PATCH] Use std::error_code instead of llvm::error_code. This is an update for a llvm api change. llvm-svn: 210689 --- lld/include/lld/Core/Error.h | 5 ++--- lld/include/lld/Core/LLVM.h | 1 - lld/include/lld/Driver/CoreInputGraph.h | 4 ++-- lld/lib/Core/Error.cpp | 10 +++++----- lld/lib/Driver/GnuLdDriver.cpp | 2 +- lld/lib/ReaderWriter/ELF/DefaultLayout.h | 2 +- lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp | 6 +++--- .../MachO/MachONormalizedFileBinaryReader.cpp | 16 ++++++++-------- .../MachO/MachONormalizedFileBinaryWriter.cpp | 6 +++--- lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp | 4 ++-- lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.h | 1 - lld/lib/ReaderWriter/Reader.cpp | 2 +- lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp | 2 +- 13 files changed, 29 insertions(+), 32 deletions(-) diff --git a/lld/include/lld/Core/Error.h b/lld/include/lld/Core/Error.h index d59520a..12f8c2e 100644 --- a/lld/include/lld/Core/Error.h +++ b/lld/include/lld/Core/Error.h @@ -95,8 +95,7 @@ llvm::error_code make_dynamic_error_code(const Twine &msg); } // end namespace lld -namespace llvm { - +namespace std { template <> struct is_error_code_enum : std::true_type {}; template <> struct is_error_code_enum : std::true_type {}; @@ -104,6 +103,6 @@ template <> struct is_error_code_enum : std::true_type {}; template <> struct is_error_code_enum : std::true_type {}; template <> struct is_error_code_enum : std::true_type {}; -} // end namespace llvm +} #endif diff --git a/lld/include/lld/Core/LLVM.h b/lld/include/lld/Core/LLVM.h index 6ad86d6..ed97421 100644 --- a/lld/include/lld/Core/LLVM.h +++ b/lld/include/lld/Core/LLVM.h @@ -38,7 +38,6 @@ namespace llvm { template class ErrorOr; - class error_code; class raw_ostream; // TODO: DenseMap, ... } diff --git a/lld/include/lld/Driver/CoreInputGraph.h b/lld/include/lld/Driver/CoreInputGraph.h index 0152d6d..c84eb0e 100644 --- a/lld/include/lld/Driver/CoreInputGraph.h +++ b/lld/include/lld/Driver/CoreInputGraph.h @@ -34,8 +34,8 @@ public: /// \brief Parse the input file to lld::File. error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override { ErrorOr filePath = getPath(ctx); - if (filePath.getError() == llvm::errc::no_such_file_or_directory) - return make_error_code(llvm::errc::no_such_file_or_directory); + if (filePath.getError() == std::errc::no_such_file_or_directory) + return make_error_code(std::errc::no_such_file_or_directory); // Create a memory buffer std::unique_ptr mb; diff --git a/lld/lib/Core/Error.cpp b/lld/lib/Core/Error.cpp index 9944e11..8b75d17 100644 --- a/lld/lib/Core/Error.cpp +++ b/lld/lib/Core/Error.cpp @@ -45,7 +45,7 @@ public: default_error_condition(int ev) const LLVM_NOEXCEPT override { if (NativeReaderError(ev) == NativeReaderError::success) return llvm::error_condition(); - return llvm::errc::invalid_argument; + return std::errc::invalid_argument; } }; @@ -75,7 +75,7 @@ public: default_error_condition(int ev) const LLVM_NOEXCEPT override { if (YamlReaderError(ev) == YamlReaderError::success) return llvm::error_condition(); - return llvm::errc::invalid_argument; + return std::errc::invalid_argument; } }; @@ -106,7 +106,7 @@ public: LinkerScriptReaderError e = LinkerScriptReaderError(ev); if (e == LinkerScriptReaderError::success) return llvm::error_condition(); - return llvm::errc::invalid_argument; + return std::errc::invalid_argument; } }; @@ -132,7 +132,7 @@ public: default_error_condition(int ev) const LLVM_NOEXCEPT override { if (InputGraphError(ev) == InputGraphError::success) return llvm::error_condition(); - return llvm::errc::invalid_argument; + return std::errc::invalid_argument; } }; @@ -161,7 +161,7 @@ public: default_error_condition(int ev) const LLVM_NOEXCEPT override { if (ReaderError(ev) == ReaderError::success) return llvm::error_condition(); - return llvm::errc::invalid_argument; + return std::errc::invalid_argument; } }; diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp index ef5bfa8..ea98251 100644 --- a/lld/lib/Driver/GnuLdDriver.cpp +++ b/lld/lib/Driver/GnuLdDriver.cpp @@ -159,7 +159,7 @@ llvm::ErrorOr ELFFileNode::getPath(const LinkingContext &) const { } std::string ELFFileNode::errStr(error_code errc) { - if (errc == llvm::errc::no_such_file_or_directory) { + if (errc == std::errc::no_such_file_or_directory) { if (_attributes._isDashlPrefix) return (Twine("Unable to find library -l") + _path).str(); return (Twine("Unable to find file ") + _path).str(); diff --git a/lld/lib/ReaderWriter/ELF/DefaultLayout.h b/lld/lib/ReaderWriter/ELF/DefaultLayout.h index 3cf702a..6c72737 100644 --- a/lld/lib/ReaderWriter/ELF/DefaultLayout.h +++ b/lld/lib/ReaderWriter/ELF/DefaultLayout.h @@ -546,7 +546,7 @@ ErrorOr DefaultLayout::addAtom(const Atom *atom) // undefined atoms can still be included in the output symbol table for // -noinhibit-exec. if (definedAtom->contentType() == DefinedAtom::typeUnknown) - return make_error_code(llvm::errc::invalid_argument); + return make_error_code(std::errc::invalid_argument); const DefinedAtom::ContentPermissions permissions = definedAtom->permissions(); const DefinedAtom::ContentType contentType = definedAtom->contentType(); diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp index 89f5022..b7310da 100644 --- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp @@ -178,7 +178,7 @@ ErrorOr ELFLinkingContext::searchLibrary(StringRef libName) const { return StringRef(*new (_allocator) std::string(path.str())); } if (!llvm::sys::fs::exists(libName)) - return llvm::make_error_code(llvm::errc::no_such_file_or_directory); + return llvm::make_error_code(std::errc::no_such_file_or_directory); return libName; } @@ -195,7 +195,7 @@ ErrorOr ELFLinkingContext::searchFile(StringRef fileName, return fileName; if (llvm::sys::path::is_absolute(fileName)) - return llvm::make_error_code(llvm::errc::no_such_file_or_directory); + return llvm::make_error_code(std::errc::no_such_file_or_directory); for (StringRef dir : _inputSearchPaths) { buildSearchPath(path, dir, _sysrootPath); @@ -203,7 +203,7 @@ ErrorOr ELFLinkingContext::searchFile(StringRef fileName, if (llvm::sys::fs::exists(path.str())) return StringRef(*new (_allocator) std::string(path.str())); } - return llvm::make_error_code(llvm::errc::no_such_file_or_directory); + return llvm::make_error_code(std::errc::no_such_file_or_directory); } void ELFLinkingContext::createInternalFiles( diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp index f97defd..65146e4 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp @@ -65,7 +65,7 @@ forEachLoadCommand(StringRef lcRange, unsigned lcCount, bool swap, bool is64, slc = &lcCopy; } if ( (p + slc->cmdsize) > lcRange.end() ) - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); if (func(slc->cmd, slc->cmdsize, p)) return error_code(); @@ -81,7 +81,7 @@ static error_code appendRelocations(Relocations &relocs, StringRef buffer, bool swap, bool bigEndian, uint32_t reloff, uint32_t nreloc) { if ((reloff + nreloc*8) > buffer.size()) - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); const any_relocation_info* relocsArray = reinterpret_cast(buffer.begin()+reloff); @@ -96,9 +96,9 @@ appendIndirectSymbols(IndirectSymbols &isyms, StringRef buffer, bool swap, bool bigEndian, uint32_t istOffset, uint32_t istCount, uint32_t startIndex, uint32_t count) { if ((istOffset + istCount*4) > buffer.size()) - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); if (startIndex+count > istCount) - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); const uint32_t *indirectSymbolArray = reinterpret_cast(buffer.begin()+istOffset); @@ -146,12 +146,12 @@ readBinary(std::unique_ptr &mb, fa++; } if (!foundArch) { - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); } objSize = readBigEndian(fa->size); uint32_t offset = readBigEndian(fa->offset); if ((offset + objSize) > mb->getBufferSize()) - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); start += offset; mh = reinterpret_cast(start); } @@ -175,7 +175,7 @@ readBinary(std::unique_ptr &mb, swap = true; break; default: - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); } // Endian swap header, if needed. @@ -193,7 +193,7 @@ readBinary(std::unique_ptr &mb, start + (is64 ? sizeof(mach_header_64) : sizeof(mach_header)); StringRef lcRange(lcStart, smh->sizeofcmds); if (lcRange.end() > (start + objSize)) - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); // Normalize architecture f->arch = MachOLinkingContext::archFromCpuType(smh->cputype, smh->cpusubtype); diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp index 4a39a4b..8693556 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp @@ -380,7 +380,7 @@ void MachOFileLayout::buildFileOffsets() { if (&sg1 == &sg2) continue; if (overlaps(sg1,sg2)) { - _ec = llvm::make_error_code(llvm::errc::executable_format_error); + _ec = llvm::make_error_code(std::errc::executable_format_error); return; } } @@ -392,7 +392,7 @@ void MachOFileLayout::buildFileOffsets() { if (&s1 == &s2) continue; if (overlaps(s1,s2)) { - _ec = llvm::make_error_code(llvm::errc::executable_format_error); + _ec = llvm::make_error_code(std::errc::executable_format_error); return; } } @@ -413,7 +413,7 @@ void MachOFileLayout::buildFileOffsets() { if ((s.address >= sg.address) && (s.address+s.content.size() <= sg.address+sg.size)) { if (!sg.name.equals(s.segmentName)) { - _ec = llvm::make_error_code(llvm::errc::executable_format_error); + _ec = llvm::make_error_code(std::errc::executable_format_error); return; } _segInfo[&sg].sections.push_back(&s); diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp index 4752097..ed1448a 100644 --- a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp @@ -977,7 +977,7 @@ private: std::string programPath = llvm::sys::FindProgramByName(program); if (programPath.empty()) { llvm::errs() << "Unable to find " << program << " in PATH\n"; - return llvm::errc::broken_pipe; + return std::errc::broken_pipe; } std::vector args; args.push_back(programPath.c_str()); @@ -996,7 +996,7 @@ private: if (llvm::sys::ExecuteAndWait(programPath.c_str(), &args[0]) != 0) { llvm::errs() << program << " failed\n"; - return llvm::errc::broken_pipe; + return std::errc::broken_pipe; } return outFilePath.str().str(); } diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.h b/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.h index eee9786..4f9eb0b 100644 --- a/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.h +++ b/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.h @@ -15,7 +15,6 @@ namespace llvm { class MemoryBuffer; -class error_code; } namespace lld { diff --git a/lld/lib/ReaderWriter/Reader.cpp b/lld/lib/ReaderWriter/Reader.cpp index ce81c69..39effa6 100644 --- a/lld/lib/ReaderWriter/Reader.cpp +++ b/lld/lib/ReaderWriter/Reader.cpp @@ -44,7 +44,7 @@ Registry::parseFile(std::unique_ptr &mb, return reader->parseFile(mb, *this, result); // No Reader could parse this file. - return llvm::make_error_code(llvm::errc::executable_format_error); + return llvm::make_error_code(std::errc::executable_format_error); } static const Registry::KindStrings kindStrings[] = { diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp index 29c2efa..7fe156b 100644 --- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp +++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp @@ -1252,7 +1252,7 @@ public: std::string errorInfo; llvm::raw_fd_ostream out(outPath.data(), errorInfo, llvm::sys::fs::F_Text); if (!errorInfo.empty()) - return llvm::make_error_code(llvm::errc::no_such_file_or_directory); + return llvm::make_error_code(std::errc::no_such_file_or_directory); // Create yaml Output writer, using yaml options for context. YamlContext yamlContext; -- 2.7.4