[llvm] 365053d - Support: Remove code duplication for mapped_file_region accessors, NFC

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 9 11:51:14 PDT 2021


Author: Duncan P. N. Exon Smith
Date: 2021-04-09T11:49:40-07:00
New Revision: 365053d2a55b5e045354f3c3d0d0cc7f5810f457

URL: https://github.com/llvm/llvm-project/commit/365053d2a55b5e045354f3c3d0d0cc7f5810f457
DIFF: https://github.com/llvm/llvm-project/commit/365053d2a55b5e045354f3c3d0d0cc7f5810f457.diff

LOG: Support: Remove code duplication for mapped_file_region accessors, NFC

Added: 
    

Modified: 
    llvm/lib/Support/Path.cpp
    llvm/lib/Support/Unix/Path.inc
    llvm/lib/Support/Windows/Path.inc

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index f49affb3fa99b..005c27c3a42af 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -1152,6 +1152,21 @@ ErrorOr<perms> getPermissions(const Twine &Path) {
   return Status.permissions();
 }
 
+size_t mapped_file_region::size() const {
+  assert(Mapping && "Mapping failed but used anyway!");
+  return Size;
+}
+
+char *mapped_file_region::data() const {
+  assert(Mapping && "Mapping failed but used anyway!");
+  return reinterpret_cast<char *>(Mapping);
+}
+
+const char *mapped_file_region::const_data() const {
+  assert(Mapping && "Mapping failed but used anyway!");
+  return reinterpret_cast<const char *>(Mapping);
+}
+
 } // end namespace fs
 } // end namespace sys
 } // end namespace llvm

diff  --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index a7e47840078e6..28a0bfa873763 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -858,21 +858,6 @@ mapped_file_region::~mapped_file_region() {
     ::munmap(Mapping, Size);
 }
 
-size_t mapped_file_region::size() const {
-  assert(Mapping && "Mapping failed but used anyway!");
-  return Size;
-}
-
-char *mapped_file_region::data() const {
-  assert(Mapping && "Mapping failed but used anyway!");
-  return reinterpret_cast<char*>(Mapping);
-}
-
-const char *mapped_file_region::const_data() const {
-  assert(Mapping && "Mapping failed but used anyway!");
-  return reinterpret_cast<const char*>(Mapping);
-}
-
 int mapped_file_region::alignment() {
   return Process::getPageSizeEstimate();
 }

diff  --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 4a6d4a4cd1b08..72c0bf2cf8aa6 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -947,21 +947,6 @@ mapped_file_region::~mapped_file_region() {
   }
 }
 
-size_t mapped_file_region::size() const {
-  assert(Mapping && "Mapping failed but used anyway!");
-  return Size;
-}
-
-char *mapped_file_region::data() const {
-  assert(Mapping && "Mapping failed but used anyway!");
-  return reinterpret_cast<char*>(Mapping);
-}
-
-const char *mapped_file_region::const_data() const {
-  assert(Mapping && "Mapping failed but used anyway!");
-  return reinterpret_cast<const char*>(Mapping);
-}
-
 int mapped_file_region::alignment() {
   SYSTEM_INFO SysInfo;
   ::GetSystemInfo(&SysInfo);


        


More information about the llvm-commits mailing list