Finishing touch for the std::error_code transition.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 13 Jun 2014 17:20:48 +0000 (17:20 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 13 Jun 2014 17:20:48 +0000 (17:20 +0000)
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

16 files changed:
include/llvm/Support/Errc.h [new file with mode: 0644]
include/llvm/Support/ErrorOr.h
lib/Support/FileOutputBuffer.cpp
lib/Support/LockFileManager.cpp
lib/Support/MemoryBuffer.cpp
lib/Support/Path.cpp
lib/Support/Unix/Path.inc
lib/Support/Windows/Path.inc
lib/Support/WindowsError.cpp
lib/Support/YAMLTraits.cpp
tools/llvm-ar/llvm-ar.cpp
tools/llvm-cov/llvm-cov.cpp
tools/llvm-symbolizer/LLVMSymbolize.cpp
unittests/Support/ErrorOrTest.cpp
unittests/Support/Path.cpp
unittests/Transforms/DebugIR/DebugIR.cpp

diff --git a/include/llvm/Support/Errc.h b/include/llvm/Support/Errc.h
new file mode 100644 (file)
index 0000000..80bfe2a
--- /dev/null
@@ -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 <system_error>
+
+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<int>(E), std::generic_category());
+}
+}
+
+namespace std {
+template <> struct is_error_code_enum<llvm::errc> : std::true_type {};
+}
+#endif
index fc111109fcd2b1593a3a494146bf76d47250ce72..0742a2d06f71b020e023b5e7832ba85be5957ba3 100644 (file)
@@ -99,7 +99,6 @@ public:
                                       std::is_error_condition_enum<E>::value,
                                   void *>::type = 0)
       : HasError(true) {
-    using std::make_error_code;
     new (getErrorStorage()) std::error_code(make_error_code(ErrorCode));
   }
 
index 8a7b0d73f94367ece8350375896a97d5608cf8e3..2e740ca04518dd4bb57e9cb17077b324a7316335 100644 (file)
@@ -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.
index 0ca631cb63466d61c2d1085a3720efe646ccbd93..681bae2ba1835040b47d8f0d7f84ae62d244afea 100644 (file)
@@ -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;
     }
index 8ff4e7c4dc3e9f88af03b58d7d848eb03a998db7..abf4f60b27a61487fd8c9b1e0e270ddab9f42770 100644 (file)
@@ -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<MemoryBuffer> SB(Buf);
index 1f843d8f2ae30982250dd79c010ec585bd3313af..15edf0ddbbd8a4886cef70244aec7b2f8fddcdd7 100644 (file)
@@ -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
index 824673649c3e3fd8976d7478a4adda6289a25675..c9fae4298689bfef27e8367662cb3bbf8413417c 100644 (file)
@@ -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<size_t>::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<size_t>::max()) {
-    ec = make_error_code(std::errc::invalid_argument);
+    ec = make_error_code(errc::invalid_argument);
     return;
   }
 
index 72f21ae5e68ede83f8e1cd0e32cc3529ab9c8f6c..7a1bc0447faca05eb381ef9c7b15d8cbff576ee4 100644 (file)
@@ -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;
   }
 
index e54ac36314cf00acda8fb7694c791933a7dbe591..18fdbbda9f1c5a8f656a98f2b56d043765e446fe 100644 (file)
 //  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) {
index 0bf9cf89088b543ebd5e0a6e67ad70941f6327da..5212624f0cd3f1f6b7a86c1e836b0ea84976631b 100644 (file)
@@ -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) {
index 227adb4421598263d43f2fdc63804ebe47153952..f5f28cf8a182c90134d8a420a9ab5f58e7dbd621 100644 (file)
@@ -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<MemoryBuffer> 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 + "'");
index b233a90bf58563093551d6fc4d356d6812a3690c..0a64d76c3741c87a82e3096aedc7dbbcb70fe440 100644 (file)
@@ -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<MemoryBuffer> 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;
     }
index c6bd4e7abfc4648b37a7eaa56ffb69a563df14f8..dd9ffc1fb8ed3e9496ce3d3446ecc92bb163a8b7 100644 (file)
@@ -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<Binary>(DbgBin));
       }
index 976a95379a114f2e302f93fe8960ff5c4c6e3496..d76e7d62421fb98d016b4e8614d357f18f7c5a72 100644 (file)
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/Errc.h"
 #include "gtest/gtest.h"
 #include <memory>
 
@@ -16,7 +17,7 @@ using namespace llvm;
 namespace {
 
 ErrorOr<int> t1() {return 1;}
-ErrorOr<int> t2() { return std::errc::invalid_argument; }
+ErrorOr<int> t2() { return errc::invalid_argument; }
 
 TEST(ErrorOr, SimpleValue) {
   ErrorOr<int> 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
index babeb53a114790ec9f7119634a8a4feb247d7f9c..da1bd2239577d9afda4576bbb18901873c16f796 100644 (file)
@@ -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"));
 }
 
index c4ebc5cfa4aebd4e1b3890c66f3adfc76dd48651..41df14721684d6445081924a88a5bb7312f8990b 100644 (file)
@@ -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() {