Use an enum class.

llvm-svn: 210078
This commit is contained in:
Rafael Espindola 2014-06-03 05:26:12 +00:00
parent 92512e89a2
commit e00fec8fe4
2 changed files with 10 additions and 19 deletions

View File

@ -21,18 +21,12 @@ namespace object {
const error_category &object_category();
struct object_error {
enum Impl {
success = 0,
arch_not_found,
invalid_file_type,
parse_failed,
unexpected_eof
};
Impl V;
object_error(Impl V) : V(V) {}
operator Impl() const { return V; }
enum class object_error {
success = 0,
arch_not_found,
invalid_file_type,
parse_failed,
unexpected_eof
};
inline error_code make_error_code(object_error e) {
@ -43,9 +37,6 @@ inline error_code make_error_code(object_error e) {
template <> struct is_error_code_enum<object::object_error> : std::true_type {};
template <>
struct is_error_code_enum<object::object_error::Impl> : std::true_type {};
} // end namespace llvm.
#endif

View File

@ -30,8 +30,8 @@ const char *_object_error_category::name() const {
return "llvm.object";
}
std::string _object_error_category::message(int ev) const {
object_error::Impl E = static_cast<object_error::Impl>(ev);
std::string _object_error_category::message(int EV) const {
object_error E = static_cast<object_error>(EV);
switch (E) {
case object_error::success: return "Success";
case object_error::arch_not_found:
@ -47,8 +47,8 @@ std::string _object_error_category::message(int ev) const {
"defined.");
}
error_condition _object_error_category::default_error_condition(int ev) const {
if (ev == object_error::success)
error_condition _object_error_category::default_error_condition(int EV) const {
if (static_cast<object_error>(EV) == object_error::success)
return error_condition();
return errc::invalid_argument;
}