From d8b23109b26f2070e21d5515ed2472ca9ab0111c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 13 Jun 2014 17:20:48 +0000 Subject: Finishing touch for the std::error_code transition. While std::error_code itself seems to work OK in all platforms, there are few annoying differences with regards to the std::errc enumeration. This patch adds a simple llvm enumeration, which will hopefully avoid build breakages in other platforms and surprises as we get more uses of std::error_code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210920 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-ar/llvm-ar.cpp | 7 ++++--- tools/llvm-cov/llvm-cov.cpp | 3 ++- tools/llvm-symbolizer/LLVMSymbolize.cpp | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 227adb4421..f5f28cf8a1 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -17,6 +17,7 @@ #include "llvm/Object/Archive.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" @@ -453,7 +454,7 @@ int NewArchiveIterator::getFD() const { // Linux cannot open directories with open(2), although // cygwin and *bsd can. if (NewStatus.type() == sys::fs::file_type::directory_file) - failIfError(std::make_error_code(std::errc::is_a_directory), NewFilename); + failIfError(make_error_code(errc::is_a_directory), NewFilename); return NewFD; } @@ -939,7 +940,7 @@ static int performOperation(ArchiveOperation Operation) { // Create or open the archive object. std::unique_ptr Buf; std::error_code EC = MemoryBuffer::getFile(ArchiveName, Buf, -1, false); - if (EC && EC != std::errc::no_such_file_or_directory) { + if (EC && EC != errc::no_such_file_or_directory) { errs() << ToolName << ": error opening '" << ArchiveName << "': " << EC.message() << "!\n"; return 1; @@ -957,7 +958,7 @@ static int performOperation(ArchiveOperation Operation) { return 0; } - assert(EC == std::errc::no_such_file_or_directory); + assert(EC == errc::no_such_file_or_directory); if (!shouldCreateArchive(Operation)) { failIfError(EC, Twine("error loading '") + ArchiveName + "'"); diff --git a/tools/llvm-cov/llvm-cov.cpp b/tools/llvm-cov/llvm-cov.cpp index b233a90bf5..0a64d76c37 100644 --- a/tools/llvm-cov/llvm-cov.cpp +++ b/tools/llvm-cov/llvm-cov.cpp @@ -13,6 +13,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/GCOV.h" #include "llvm/Support/ManagedStatic.h" @@ -116,7 +117,7 @@ int main(int argc, char **argv) { std::unique_ptr GCDA_Buff; if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) { - if (ec != std::errc::no_such_file_or_directory) { + if (ec != errc::no_such_file_or_directory) { errs() << InputGCDA << ": " << ec.message() << "\n"; return 1; } diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp index c6bd4e7abf..dd9ffc1fb8 100644 --- a/tools/llvm-symbolizer/LLVMSymbolize.cpp +++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" #include "llvm/Support/DataExtractor.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -311,7 +312,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { getDarwinDWARFResourceForPath(Path); BinaryOrErr = createBinary(ResourcePath); std::error_code EC = BinaryOrErr.getError(); - if (EC != std::errc::no_such_file_or_directory && !error(EC)) { + if (EC != errc::no_such_file_or_directory && !error(EC)) { DbgBin = BinaryOrErr.get(); ParsedBinariesAndObjects.push_back(std::unique_ptr(DbgBin)); } -- cgit v1.2.3