[llvm] r239683 - Don't use std::errc.
Rafael Espindola
rafael.espindola at gmail.com
Sat Jun 13 10:23:05 PDT 2015
Author: rafael
Date: Sat Jun 13 12:23:04 2015
New Revision: 239683
URL: http://llvm.org/viewvc/llvm-project?rev=239683&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Object/ArchiveWriter.cpp
llvm/trunk/lib/ProfileData/CoverageMapping.cpp
llvm/trunk/lib/Support/Unix/Program.inc
llvm/trunk/lib/Support/Windows/Program.inc
llvm/trunk/unittests/Support/ErrorOrTest.cpp
Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=239683&r1=239682&r2=239683&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Sat Jun 13 12:23:04 2015
@@ -18,6 +18,7 @@
#include "llvm/Object/Archive.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/SymbolicFile.h"
+#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Path.h"
@@ -70,7 +71,7 @@ NewArchiveIterator::getFD(sys::fs::file_
// Linux cannot open directories with open(2), although
// cygwin and *bsd can.
if (NewStatus.type() == sys::fs::file_type::directory_file)
- return make_error_code(std::errc::is_a_directory);
+ return make_error_code(errc::is_a_directory);
return NewFD;
}
Modified: llvm/trunk/lib/ProfileData/CoverageMapping.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/CoverageMapping.cpp?rev=239683&r1=239682&r2=239683&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/CoverageMapping.cpp (original)
+++ llvm/trunk/lib/ProfileData/CoverageMapping.cpp Sat Jun 13 12:23:04 2015
@@ -19,6 +19,7 @@
#include "llvm/ProfileData/CoverageMappingReader.h"
#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Path.h"
@@ -154,11 +155,11 @@ ErrorOr<int64_t> CounterMappingContext::
return 0;
case Counter::CounterValueReference:
if (C.getCounterID() >= CounterValues.size())
- return std::make_error_code(std::errc::argument_out_of_domain);
+ return make_error_code(errc::argument_out_of_domain);
return CounterValues[C.getCounterID()];
case Counter::Expression: {
if (C.getExpressionID() >= Expressions.size())
- return std::make_error_code(std::errc::argument_out_of_domain);
+ return make_error_code(errc::argument_out_of_domain);
const auto &E = Expressions[C.getExpressionID()];
ErrorOr<int64_t> LHS = evaluate(E.LHS);
if (!LHS)
Modified: llvm/trunk/lib/Support/Unix/Program.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Program.inc?rev=239683&r1=239682&r2=239683&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Program.inc (original)
+++ llvm/trunk/lib/Support/Unix/Program.inc Sat Jun 13 12:23:04 2015
@@ -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<std::string> sys::findProgramByN
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(StringR
OS << Contents;
if (OS.has_error())
- return std::make_error_code(std::errc::io_error);
+ return make_error_code(errc::io_error);
return EC;
}
Modified: llvm/trunk/lib/Support/Windows/Program.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Program.inc?rev=239683&r1=239682&r2=239683&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Program.inc (original)
+++ llvm/trunk/lib/Support/Windows/Program.inc Sat Jun 13 12:23:04 2015
@@ -14,6 +14,7 @@
#include "WindowsSupport.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/WindowsError.h"
#include "llvm/Support/raw_ostream.h"
@@ -514,7 +515,7 @@ llvm::sys::writeFileWithEncoding(StringR
}
if (OS.has_error())
- return std::make_error_code(std::errc::io_error);
+ return make_error_code(errc::io_error);
return EC;
}
Modified: llvm/trunk/unittests/Support/ErrorOrTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ErrorOrTest.cpp?rev=239683&r1=239682&r2=239683&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ErrorOrTest.cpp (original)
+++ llvm/trunk/unittests/Support/ErrorOrTest.cpp Sat Jun 13 12:23:04 2015
@@ -67,8 +67,8 @@ TEST(ErrorOr, Covariant) {
}
TEST(ErrorOr, Comparison) {
- ErrorOr<int> x(std::errc::no_such_file_or_directory);
- EXPECT_EQ(x, std::errc::no_such_file_or_directory);
+ ErrorOr<int> x(errc::no_such_file_or_directory);
+ EXPECT_EQ(x, errc::no_such_file_or_directory);
}
// ErrorOr<int*> x(nullptr);
More information about the llvm-commits
mailing list