From 74f293249d9e60e3631fc8b08148ef3d8a4df72d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 13 Jun 2015 17:23:04 +0000 Subject: Don't use std::errc. As noted on Errc.h: // * 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. And on some libstdc++ those virtual functions conclude that ------------------------ int main() { std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory); return foo == std::errc::no_such_file_or_directory; } ------------------------- should exit with 0. llvm-svn: 239683 --- llvm/lib/Support/Unix/Program.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Support/Unix/Program.inc') diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index 5816fb812e9..8947b62e4dc 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -20,6 +20,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" @@ -92,7 +93,7 @@ ErrorOr sys::findProgramByName(StringRef Name, if (sys::fs::can_execute(FilePath.c_str())) return std::string(FilePath.str()); // Found the executable! } - return std::errc::no_such_file_or_directory; + return errc::no_such_file_or_directory; } static bool RedirectIO(const StringRef *Path, int FD, std::string* ErrMsg) { @@ -447,7 +448,7 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents, OS << Contents; if (OS.has_error()) - return std::make_error_code(std::errc::io_error); + return make_error_code(errc::io_error); return EC; } -- cgit v1.2.3