[Lldb-commits] [lldb] 2165c36 - [lldb] Return a DataBuffer from FileSystem::CreateDataBuffer (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 1 17:31:49 PDT 2022


Author: Jonas Devlieghere
Date: 2022-04-01T17:31:20-07:00
New Revision: 2165c36be44589a0d78c6ac23389d69a5d390dc5

URL: https://github.com/llvm/llvm-project/commit/2165c36be44589a0d78c6ac23389d69a5d390dc5
DIFF: https://github.com/llvm/llvm-project/commit/2165c36be44589a0d78c6ac23389d69a5d390dc5.diff

LOG: [lldb] Return a DataBuffer from FileSystem::CreateDataBuffer (NFC)

The concrete class (DataBufferLLVM) is an implementation detail.

Added: 
    

Modified: 
    lldb/include/lldb/Host/FileSystem.h
    lldb/include/lldb/Utility/DataBufferLLVM.h
    lldb/source/Commands/CommandObjectMemory.cpp
    lldb/source/Core/SourceManager.cpp
    lldb/source/Host/common/FileSystem.cpp
    lldb/source/Host/common/Host.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h
index efa77cbbbcb96..feb2051812b0a 100644
--- a/lldb/include/lldb/Host/FileSystem.h
+++ b/lldb/include/lldb/Host/FileSystem.h
@@ -10,7 +10,7 @@
 #define LLDB_HOST_FILESYSTEM_H
 
 #include "lldb/Host/File.h"
-#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 
@@ -142,12 +142,12 @@ class FileSystem {
 
   //// Create memory buffer from path.
   /// \{
-  std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const llvm::Twine &path,
-                                                   uint64_t size = 0,
-                                                   uint64_t offset = 0);
-  std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const FileSpec &file_spec,
-                                                   uint64_t size = 0,
-                                                   uint64_t offset = 0);
+  std::shared_ptr<DataBuffer> CreateDataBuffer(const llvm::Twine &path,
+                                               uint64_t size = 0,
+                                               uint64_t offset = 0);
+  std::shared_ptr<DataBuffer> CreateDataBuffer(const FileSpec &file_spec,
+                                               uint64_t size = 0,
+                                               uint64_t offset = 0);
   /// \}
 
   /// Call into the Host to see if it can help find the file.

diff  --git a/lldb/include/lldb/Utility/DataBufferLLVM.h b/lldb/include/lldb/Utility/DataBufferLLVM.h
index abb1bb40d534a..eeb17c51f6e13 100644
--- a/lldb/include/lldb/Utility/DataBufferLLVM.h
+++ b/lldb/include/lldb/Utility/DataBufferLLVM.h
@@ -18,7 +18,7 @@
 namespace llvm {
 class WritableMemoryBuffer;
 class Twine;
-}
+} // namespace llvm
 
 namespace lldb_private {
 
@@ -31,8 +31,6 @@ class DataBufferLLVM : public DataBuffer {
   const uint8_t *GetBytes() const override;
   lldb::offset_t GetByteSize() const override;
 
-  char *GetChars() { return reinterpret_cast<char *>(GetBytes()); }
-
 private:
   friend FileSystem;
   /// Construct a DataBufferLLVM from \p Buffer.  \p Buffer must be a valid
@@ -41,6 +39,6 @@ class DataBufferLLVM : public DataBuffer {
 
   std::unique_ptr<llvm::WritableMemoryBuffer> Buffer;
 };
-}
+} // namespace lldb_private
 
 #endif

diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index 35f524468b895..381a41e8ae67b 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -33,7 +33,6 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/Args.h"
 #include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/DataBufferLLVM.h"
 #include "lldb/Utility/StreamString.h"
 #include "llvm/Support/MathExtras.h"
 #include <cinttypes>

diff  --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index effba485f0262..2e3835d5f451f 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -25,7 +25,6 @@
 #include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/DataBuffer.h"
-#include "lldb/Utility/DataBufferLLVM.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/lldb-enumerations.h"

diff  --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp
index 358274e9d2fb1..683b6716b47cc 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Host/FileSystem.h"
 
+#include "lldb/Utility/DataBufferLLVM.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/TildeExpressionResolver.h"
 
@@ -272,7 +273,7 @@ void FileSystem::Resolve(FileSpec &file_spec) {
   file_spec.SetIsResolved(true);
 }
 
-std::shared_ptr<DataBufferLLVM>
+std::shared_ptr<DataBuffer>
 FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
                              uint64_t offset) {
   const bool is_volatile = !IsLocal(path);
@@ -293,7 +294,7 @@ FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
   return std::shared_ptr<DataBufferLLVM>(new DataBufferLLVM(std::move(buffer)));
 }
 
-std::shared_ptr<DataBufferLLVM>
+std::shared_ptr<DataBuffer>
 FileSystem::CreateDataBuffer(const FileSpec &file_spec, uint64_t size,
                              uint64_t offset) {
   return CreateDataBuffer(file_spec.GetPath(), size, offset);

diff  --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 41fae4e9fa8d8..c406901bae585 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -56,7 +56,6 @@
 #include "lldb/Host/ProcessLauncher.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
-#include "lldb/Utility/DataBufferLLVM.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
@@ -528,8 +527,9 @@ Status Host::RunShellCommand(llvm::StringRef shell_path, const Args &args,
             auto Buffer =
                 FileSystem::Instance().CreateDataBuffer(output_file_spec);
             if (error.Success())
-              command_output_ptr->assign(Buffer->GetChars(),
-                                         Buffer->GetByteSize());
+              command_output_ptr->assign(
+                  reinterpret_cast<char *>(Buffer->GetBytes()),
+                  Buffer->GetByteSize());
           }
         }
       }


        


More information about the lldb-commits mailing list