From 1d78190843e64577810bfd8a33b80256de28f2bc Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 21 Mar 2021 15:53:21 -0700
Subject: [PATCH] hle: kernel: Merge KMemoryRegionAttr and KMemoryRegionType.

- Fixes clang errors with mixed enum arithmetic.
---
 src/core/hle/kernel/k_memory_region.h      |  6 +++---
 src/core/hle/kernel/k_memory_region_type.h | 14 ++++++--------
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/core/hle/kernel/k_memory_region.h b/src/core/hle/kernel/k_memory_region.h
index 374b24bd32..782c21fbf9 100644
--- a/src/core/hle/kernel/k_memory_region.h
+++ b/src/core/hle/kernel/k_memory_region.h
@@ -91,7 +91,7 @@ public:
         return (this->GetType() | type) == this->GetType();
     }
 
-    constexpr bool HasTypeAttribute(KMemoryRegionAttr attr) const {
+    constexpr bool HasTypeAttribute(u32 attr) const {
         return (this->GetType() | attr) == this->GetType();
     }
 
@@ -103,7 +103,7 @@ public:
         pair_address = a;
     }
 
-    constexpr void SetTypeAttribute(KMemoryRegionAttr attr) {
+    constexpr void SetTypeAttribute(u32 attr) {
         type_id |= attr;
     }
 
@@ -237,7 +237,7 @@ public:
         return extents;
     }
 
-    DerivedRegionExtents GetDerivedRegionExtents(KMemoryRegionAttr type_id) const {
+    DerivedRegionExtents GetDerivedRegionExtents(u32 type_id) const {
         return GetDerivedRegionExtents(static_cast<KMemoryRegionType>(type_id));
     }
 
diff --git a/src/core/hle/kernel/k_memory_region_type.h b/src/core/hle/kernel/k_memory_region_type.h
index cf2653d280..5ea5d2cebb 100644
--- a/src/core/hle/kernel/k_memory_region_type.h
+++ b/src/core/hle/kernel/k_memory_region_type.h
@@ -13,9 +13,7 @@
 
 namespace Kernel {
 
-enum KMemoryRegionType : u32 {};
-
-enum KMemoryRegionAttr : typename std::underlying_type<KMemoryRegionType>::type {
+enum KMemoryRegionType : u32 {
     KMemoryRegionAttr_CarveoutProtected = 0x04000000,
     KMemoryRegionAttr_DidKernelMap = 0x08000000,
     KMemoryRegionAttr_ShouldKernelMap = 0x10000000,
@@ -23,7 +21,7 @@ enum KMemoryRegionAttr : typename std::underlying_type<KMemoryRegionType>::type
     KMemoryRegionAttr_NoUserMap = 0x40000000,
     KMemoryRegionAttr_LinearMapped = 0x80000000,
 };
-DECLARE_ENUM_FLAG_OPERATORS(KMemoryRegionAttr);
+DECLARE_ENUM_FLAG_OPERATORS(KMemoryRegionType);
 
 namespace impl {
 
@@ -82,8 +80,8 @@ public:
         return *this;
     }
 
-    constexpr KMemoryRegionTypeValue& SetAttribute(KMemoryRegionAttr attr) {
-        m_value |= static_cast<u32>(attr);
+    constexpr KMemoryRegionTypeValue& SetAttribute(u32 attr) {
+        m_value |= attr;
         return *this;
     }
 
@@ -95,9 +93,9 @@ public:
         return new_type;
     }
 
-    constexpr KMemoryRegionTypeValue DeriveAttribute(KMemoryRegionAttr attr) const {
+    constexpr KMemoryRegionTypeValue DeriveAttribute(u32 attr) const {
         KMemoryRegionTypeValue new_type = *this;
-        new_type.m_value |= static_cast<u32>(attr);
+        new_type.m_value |= attr;
         return new_type;
     }