From 2a826e40fa51fcae4adb564d789cafe95776e0bb Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 13 Jun 2014 17:20:48 +0000 Subject: [PATCH] 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. llvm-svn: 210920 --- llvm/include/llvm/Support/Errc.h | 86 +++++++++++++++++++ llvm/include/llvm/Support/ErrorOr.h | 1 - llvm/lib/Support/FileOutputBuffer.cpp | 3 +- llvm/lib/Support/LockFileManager.cpp | 5 +- llvm/lib/Support/MemoryBuffer.cpp | 3 +- llvm/lib/Support/Path.cpp | 7 +- llvm/lib/Support/Unix/Path.inc | 10 +-- llvm/lib/Support/Windows/Path.inc | 14 +-- llvm/lib/Support/WindowsError.cpp | 6 +- llvm/lib/Support/YAMLTraits.cpp | 7 +- llvm/tools/llvm-ar/llvm-ar.cpp | 7 +- llvm/tools/llvm-cov/llvm-cov.cpp | 3 +- llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp | 3 +- llvm/unittests/Support/ErrorOrTest.cpp | 5 +- llvm/unittests/Support/Path.cpp | 9 +- llvm/unittests/Transforms/DebugIR/DebugIR.cpp | 3 +- 16 files changed, 134 insertions(+), 38 deletions(-) create mode 100644 llvm/include/llvm/Support/Errc.h diff --git a/llvm/include/llvm/Support/Errc.h b/llvm/include/llvm/Support/Errc.h new file mode 100644 index 000000000000..80bfe2ac2ee5 --- /dev/null +++ b/llvm/include/llvm/Support/Errc.h @@ -0,0 +1,86 @@ +//===- llvm/Support/Errc.h - Defines the llvm::errc enum --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// While std::error_code works OK on all platforms we use, there are some +// some problems with std::errc that can be avoided by using our own +// enumeration: +// +// * std::errc is a namespace in some implementations. That meas that ADL +// doesn't work and it is sometimes necessary to write std::make_error_code +// or in templates: +// using std::make_error_code; +// make_error_code(...); +// +// with this enum it is safe to always just use make_error_code. +// +// * Some implementations define fewer names than others. This header has +// the intersection of all the ones we support. +// +// * std::errc is just marked with is_error_condition_enum. This means that +// common patters like AnErrorCode == errc::no_such_file_or_directory take +// 4 virtual calls instead of two comparisons. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_ERRC_H +#define LLVM_SUPPORT_ERRC_H + +#include + +namespace llvm { +enum class errc { + argument_list_too_long = int(std::errc::argument_list_too_long), + argument_out_of_domain = int(std::errc::argument_out_of_domain), + bad_address = int(std::errc::bad_address), + bad_file_descriptor = int(std::errc::bad_file_descriptor), + broken_pipe = int(std::errc::broken_pipe), + device_or_resource_busy = int(std::errc::device_or_resource_busy), + directory_not_empty = int(std::errc::directory_not_empty), + executable_format_error = int(std::errc::executable_format_error), + file_exists = int(std::errc::file_exists), + file_too_large = int(std::errc::file_too_large), + filename_too_long = int(std::errc::filename_too_long), + function_not_supported = int(std::errc::function_not_supported), + illegal_byte_sequence = int(std::errc::illegal_byte_sequence), + inappropriate_io_control_operation = + int(std::errc::inappropriate_io_control_operation), + interrupted = int(std::errc::interrupted), + invalid_argument = int(std::errc::invalid_argument), + invalid_seek = int(std::errc::invalid_seek), + io_error = int(std::errc::io_error), + is_a_directory = int(std::errc::is_a_directory), + no_child_process = int(std::errc::no_child_process), + no_lock_available = int(std::errc::no_lock_available), + no_space_on_device = int(std::errc::no_space_on_device), + no_such_device_or_address = int(std::errc::no_such_device_or_address), + no_such_device = int(std::errc::no_such_device), + no_such_file_or_directory = int(std::errc::no_such_file_or_directory), + no_such_process = int(std::errc::no_such_process), + not_a_directory = int(std::errc::not_a_directory), + not_enough_memory = int(std::errc::not_enough_memory), + operation_not_permitted = int(std::errc::operation_not_permitted), + permission_denied = int(std::errc::permission_denied), + read_only_file_system = int(std::errc::read_only_file_system), + resource_deadlock_would_occur = int(std::errc::resource_deadlock_would_occur), + resource_unavailable_try_again = + int(std::errc::resource_unavailable_try_again), + result_out_of_range = int(std::errc::result_out_of_range), + too_many_files_open_in_system = int(std::errc::too_many_files_open_in_system), + too_many_files_open = int(std::errc::too_many_files_open), + too_many_links = int(std::errc::too_many_links) +}; + +inline std::error_code make_error_code(errc E) { + return std::error_code(static_cast(E), std::generic_category()); +} +} + +namespace std { +template <> struct is_error_code_enum : std::true_type {}; +} +#endif diff --git a/llvm/include/llvm/Support/ErrorOr.h b/llvm/include/llvm/Support/ErrorOr.h index fc111109fcd2..0742a2d06f71 100644 --- a/llvm/include/llvm/Support/ErrorOr.h +++ b/llvm/include/llvm/Support/ErrorOr.h @@ -99,7 +99,6 @@ public: std::is_error_condition_enum::value, void *>::type = 0) : HasError(true) { - using std::make_error_code; new (getErrorStorage()) std::error_code(make_error_code(ErrorCode)); } diff --git a/llvm/lib/Support/FileOutputBuffer.cpp b/llvm/lib/Support/FileOutputBuffer.cpp index 8a7b0d73f943..2e740ca04518 100644 --- a/llvm/lib/Support/FileOutputBuffer.cpp +++ b/llvm/lib/Support/FileOutputBuffer.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/Errc.h" #include "llvm/Support/FileOutputBuffer.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/raw_ostream.h" @@ -51,7 +52,7 @@ FileOutputBuffer::create(StringRef FilePath, size_t Size, if (EC) return EC; else - return std::make_error_code(std::errc::operation_not_permitted); + return make_error_code(errc::operation_not_permitted); } // Delete target file. diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 0ca631cb6346..681bae2ba183 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -9,6 +9,7 @@ #include "llvm/Support/LockFileManager.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -112,7 +113,7 @@ LockFileManager::LockFileManager(StringRef FileName) if (Out.has_error()) { // We failed to write out PID, so make up an excuse, remove the // unique lock file, and fail. - Error = std::make_error_code(std::errc::no_space_on_device); + Error = make_error_code(errc::no_space_on_device); sys::fs::remove(UniqueLockFileName.c_str()); return; } @@ -125,7 +126,7 @@ LockFileManager::LockFileManager(StringRef FileName) if (!EC) return; - if (EC != std::errc::file_exists) { + if (EC != errc::file_exists) { Error = EC; return; } diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp index 8ff4e7c4dc3e..abf4f60b27a6 100644 --- a/llvm/lib/Support/MemoryBuffer.cpp +++ b/llvm/lib/Support/MemoryBuffer.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/ADT/SmallString.h" #include "llvm/Config/config.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/Errno.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MathExtras.h" @@ -364,7 +365,7 @@ static std::error_code getOpenFileImpl(int FD, const char *Filename, if (!Buf) { // Failed to create a buffer. The only way it can fail is if // new(std::nothrow) returns 0. - return std::make_error_code(std::errc::not_enough_memory); + return make_error_code(errc::not_enough_memory); } std::unique_ptr SB(Buf); diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 1f843d8f2ae3..15edf0ddbbd8 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/Errc.h" #include "llvm/Support/Path.h" #include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" @@ -204,7 +205,7 @@ retry_random_path: if (std::error_code EC = sys::fs::openFileForWrite(Twine(ResultPath.begin()), ResultFD, sys::fs::F_RW | sys::fs::F_Excl, Mode)) { - if (EC == std::errc::file_exists) + if (EC == errc::file_exists) goto retry_random_path; return EC; } @@ -225,7 +226,7 @@ retry_random_path: case FS_Dir: { if (std::error_code EC = sys::fs::create_directory(ResultPath.begin(), false)) { - if (EC == std::errc::file_exists) + if (EC == errc::file_exists) goto retry_random_path; return EC; } @@ -830,7 +831,7 @@ std::error_code create_directories(const Twine &Path, bool IgnoreExisting) { std::error_code EC = create_directory(P, IgnoreExisting); // If we succeeded, or had any error other than the parent not existing, just // return it. - if (EC != std::errc::no_such_file_or_directory) + if (EC != errc::no_such_file_or_directory) return EC; // We failed because of a no_such_file_or_directory, try to create the diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 824673649c3e..c9fae4298689 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -317,7 +317,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { // effectively prevents LLVM from erasing things like /dev/null, any block // special file, or other things that aren't "regular" files. if (!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode) && !S_ISLNK(buf.st_mode)) - return make_error_code(std::errc::operation_not_permitted); + return make_error_code(errc::operation_not_permitted); if (::remove(p.begin()) == -1) { if (errno != ENOENT || !IgnoreNonExisting) @@ -404,7 +404,7 @@ static std::error_code fillStatus(int StatRet, const struct stat &Status, file_status &Result) { if (StatRet != 0) { std::error_code ec(errno, std::generic_category()); - if (ec == std::errc::no_such_file_or_directory) + if (ec == errc::no_such_file_or_directory) Result = file_status(file_type::file_not_found); else Result = file_status(file_type::status_error); @@ -468,7 +468,7 @@ std::error_code setLastModificationAndAccessTime(int FD, TimeValue Time) { return std::error_code(); #else #warning Missing futimes() and futimens() - return make_error_code(std::errc::not_supported); + return make_error_code(errc::not_supported); #endif } @@ -512,7 +512,7 @@ mapped_file_region::mapped_file_region(const Twine &path, , Mapping() { // Make sure that the requested size fits within SIZE_T. if (length > std::numeric_limits::max()) { - ec = make_error_code(std::errc::invalid_argument); + ec = make_error_code(errc::invalid_argument); return; } @@ -541,7 +541,7 @@ mapped_file_region::mapped_file_region(int fd, , Mapping() { // Make sure that the requested size fits within SIZE_T. if (length > std::numeric_limits::max()) { - ec = make_error_code(std::errc::invalid_argument); + ec = make_error_code(errc::invalid_argument); return; } diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc index 72f21ae5e68e..7a1bc0447fac 100644 --- a/llvm/lib/Support/Windows/Path.inc +++ b/llvm/lib/Support/Windows/Path.inc @@ -196,7 +196,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { file_status ST; if (std::error_code EC = status(path, ST)) { - if (EC != std::errc::no_such_file_or_directory || !IgnoreNonExisting) + if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting) return EC; return std::error_code(); } @@ -208,14 +208,14 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { if (ST.type() == file_type::directory_file) { if (!::RemoveDirectoryW(c_str(path_utf16))) { std::error_code EC = windows_error(::GetLastError()); - if (EC != std::errc::no_such_file_or_directory || !IgnoreNonExisting) + if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting) return EC; } return std::error_code(); } if (!::DeleteFileW(c_str(path_utf16))) { std::error_code EC = windows_error(::GetLastError()); - if (EC != std::errc::no_such_file_or_directory || !IgnoreNonExisting) + if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting) return EC; } return std::error_code(); @@ -481,7 +481,7 @@ std::error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) _close(FileDescriptor); } else ::CloseHandle(FileHandle); - return std::make_error_code(std::errc::invalid_argument); + return make_error_code(errc::invalid_argument); } DWORD flprotect; @@ -617,7 +617,7 @@ mapped_file_region::mapped_file_region(int fd, if (closefd) _close(FileDescriptor); FileDescriptor = 0; - ec = std::make_error_code(std::errc::bad_file_descriptor); + ec = make_error_code(errc::bad_file_descriptor); return; } @@ -779,7 +779,7 @@ std::error_code openFileForRead(const Twine &Name, int &ResultFD) { if (LastError != ERROR_ACCESS_DENIED) return EC; if (is_directory(Name)) - return std::make_error_code(std::errc::is_a_directory); + return make_error_code(errc::is_a_directory); return EC; } @@ -831,7 +831,7 @@ std::error_code openFileForWrite(const Twine &Name, int &ResultFD, if (LastError != ERROR_ACCESS_DENIED) return EC; if (is_directory(Name)) - return std::make_error_code(std::errc::is_a_directory); + return make_error_code(errc::is_a_directory); return EC; } diff --git a/llvm/lib/Support/WindowsError.cpp b/llvm/lib/Support/WindowsError.cpp index e54ac36314cf..18fdbbda9f1c 100644 --- a/llvm/lib/Support/WindowsError.cpp +++ b/llvm/lib/Support/WindowsError.cpp @@ -12,12 +12,12 @@ // errors to generic ones. The one implemented in msvc is too conservative // for llvm, so we do an extra mapping when constructing an error_code // from an windows error. This allows the rest of llvm to simple checks -// like "EC == std::errc::file_exists" and have it work on both posix and +// like "EC == errc::file_exists" and have it work on both posix and // windows. // //===----------------------------------------------------------------------===// - +#include "llvm/Support/Errc.h" #include "llvm/Support/WindowsError.h" #include "llvm/Config/llvm-config.h" @@ -30,7 +30,7 @@ // I'd rather not double the line count of the following. #define MAP_ERR_TO_COND(x, y) \ case x: \ - return std::make_error_code(std::errc::y) + return make_error_code(errc::y) std::error_code llvm::mapWindowsError(unsigned EV) { switch (EV) { diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp index 0bf9cf89088b..5212624f0cd3 100644 --- a/llvm/lib/Support/YAMLTraits.cpp +++ b/llvm/lib/Support/YAMLTraits.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/Errc.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Casting.h" @@ -72,7 +73,7 @@ bool Input::setCurrentDocument() { Node *N = DocIterator->getRoot(); if (!N) { assert(Strm->failed() && "Root is NULL iff parsing failed"); - EC = std::make_error_code(std::errc::invalid_argument); + EC = make_error_code(errc::invalid_argument); return false; } @@ -122,7 +123,7 @@ bool Input::preflightKey(const char *Key, bool Required, bool, bool &UseDefault, // nodes are present. if (!CurrentNode) { if (Required) - EC = std::make_error_code(std::errc::invalid_argument); + EC = make_error_code(errc::invalid_argument); return false; } @@ -298,7 +299,7 @@ void Input::setError(HNode *hnode, const Twine &message) { void Input::setError(Node *node, const Twine &message) { Strm->printError(node, message); - EC = std::make_error_code(std::errc::invalid_argument); + EC = make_error_code(errc::invalid_argument); } Input::HNode *Input::createHNodes(Node *N) { diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index 227adb442159..f5f28cf8a182 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/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/llvm/tools/llvm-cov/llvm-cov.cpp b/llvm/tools/llvm-cov/llvm-cov.cpp index b233a90bf585..0a64d76c3741 100644 --- a/llvm/tools/llvm-cov/llvm-cov.cpp +++ b/llvm/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/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp b/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp index c6bd4e7abfc4..dd9ffc1fb8ed 100644 --- a/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp +++ b/llvm/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)); } diff --git a/llvm/unittests/Support/ErrorOrTest.cpp b/llvm/unittests/Support/ErrorOrTest.cpp index 976a95379a11..d76e7d62421f 100644 --- a/llvm/unittests/Support/ErrorOrTest.cpp +++ b/llvm/unittests/Support/ErrorOrTest.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/ErrorOr.h" +#include "llvm/Support/Errc.h" #include "gtest/gtest.h" #include @@ -16,7 +17,7 @@ using namespace llvm; namespace { ErrorOr t1() {return 1;} -ErrorOr t2() { return std::errc::invalid_argument; } +ErrorOr t2() { return errc::invalid_argument; } TEST(ErrorOr, SimpleValue) { ErrorOr a = t1(); @@ -30,7 +31,7 @@ TEST(ErrorOr, SimpleValue) { a = t2(); EXPECT_FALSE(a); - EXPECT_EQ(std::errc::invalid_argument, a.getError()); + EXPECT_EQ(a.getError(), errc::invalid_argument); #ifdef EXPECT_DEBUG_DEATH EXPECT_DEBUG_DEATH(*a, "Cannot get value when an error exists"); #endif diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index babeb53a1147..da1bd2239577 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Path.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" @@ -355,10 +356,10 @@ TEST_F(FileSystemTest, TempFiles) { ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); ASSERT_EQ(fs::remove(Twine(TempPath2), false), - std::errc::no_such_file_or_directory); + errc::no_such_file_or_directory); std::error_code EC = fs::status(TempPath2.c_str(), B); - EXPECT_EQ(EC, std::errc::no_such_file_or_directory); + EXPECT_EQ(EC, errc::no_such_file_or_directory); EXPECT_EQ(B.type(), fs::file_type::file_not_found); // Make sure Temp2 doesn't exist. @@ -398,7 +399,7 @@ TEST_F(FileSystemTest, TempFiles) { "abcdefghijklmnopqrstuvwxyz3abcdefghijklmnopqrstuvwxyz2" "abcdefghijklmnopqrstuvwxyz1abcdefghijklmnopqrstuvwxyz0"; EXPECT_EQ(fs::createUniqueFile(Twine(Path270), FileDescriptor, TempPath), - std::errc::no_such_file_or_directory); + errc::no_such_file_or_directory); #endif } @@ -406,7 +407,7 @@ TEST_F(FileSystemTest, CreateDir) { ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "foo")); ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "foo")); ASSERT_EQ(fs::create_directory(Twine(TestDirectory) + "foo", false), - std::errc::file_exists); + errc::file_exists); ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "foo")); } diff --git a/llvm/unittests/Transforms/DebugIR/DebugIR.cpp b/llvm/unittests/Transforms/DebugIR/DebugIR.cpp index c4ebc5cfa4ae..41df14721684 100644 --- a/llvm/unittests/Transforms/DebugIR/DebugIR.cpp +++ b/llvm/unittests/Transforms/DebugIR/DebugIR.cpp @@ -18,6 +18,7 @@ #include "llvm/IR/DIBuilder.h" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/Module.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/Path.h" @@ -58,7 +59,7 @@ bool removeIfExists(StringRef Path) { // This is an approximation, on error we don't know in general if the file // existed or not. std::error_code EC = sys::fs::remove(Path, false); - return EC != std::errc::no_such_file_or_directory; + return EC != llvm::errc::no_such_file_or_directory; } char * current_dir() {