Skip to content

Commit 2165c36

Browse files
committed
[lldb] Return a DataBuffer from FileSystem::CreateDataBuffer (NFC)
The concrete class (DataBufferLLVM) is an implementation detail.
1 parent 492cb7b commit 2165c36

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

lldb/include/lldb/Host/FileSystem.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define LLDB_HOST_FILESYSTEM_H
1111

1212
#include "lldb/Host/File.h"
13-
#include "lldb/Utility/DataBufferLLVM.h"
13+
#include "lldb/Utility/DataBuffer.h"
1414
#include "lldb/Utility/FileSpec.h"
1515
#include "lldb/Utility/Status.h"
1616

@@ -142,12 +142,12 @@ class FileSystem {
142142

143143
//// Create memory buffer from path.
144144
/// \{
145-
std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const llvm::Twine &path,
146-
uint64_t size = 0,
147-
uint64_t offset = 0);
148-
std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const FileSpec &file_spec,
149-
uint64_t size = 0,
150-
uint64_t offset = 0);
145+
std::shared_ptr<DataBuffer> CreateDataBuffer(const llvm::Twine &path,
146+
uint64_t size = 0,
147+
uint64_t offset = 0);
148+
std::shared_ptr<DataBuffer> CreateDataBuffer(const FileSpec &file_spec,
149+
uint64_t size = 0,
150+
uint64_t offset = 0);
151151
/// \}
152152

153153
/// Call into the Host to see if it can help find the file.

lldb/include/lldb/Utility/DataBufferLLVM.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace llvm {
1919
class WritableMemoryBuffer;
2020
class Twine;
21-
}
21+
} // namespace llvm
2222

2323
namespace lldb_private {
2424

@@ -31,8 +31,6 @@ class DataBufferLLVM : public DataBuffer {
3131
const uint8_t *GetBytes() const override;
3232
lldb::offset_t GetByteSize() const override;
3333

34-
char *GetChars() { return reinterpret_cast<char *>(GetBytes()); }
35-
3634
private:
3735
friend FileSystem;
3836
/// Construct a DataBufferLLVM from \p Buffer. \p Buffer must be a valid
@@ -41,6 +39,6 @@ class DataBufferLLVM : public DataBuffer {
4139

4240
std::unique_ptr<llvm::WritableMemoryBuffer> Buffer;
4341
};
44-
}
42+
} // namespace lldb_private
4543

4644
#endif

lldb/source/Commands/CommandObjectMemory.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "lldb/Target/Thread.h"
3434
#include "lldb/Utility/Args.h"
3535
#include "lldb/Utility/DataBufferHeap.h"
36-
#include "lldb/Utility/DataBufferLLVM.h"
3736
#include "lldb/Utility/StreamString.h"
3837
#include "llvm/Support/MathExtras.h"
3938
#include <cinttypes>

lldb/source/Core/SourceManager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "lldb/Utility/AnsiTerminal.h"
2626
#include "lldb/Utility/ConstString.h"
2727
#include "lldb/Utility/DataBuffer.h"
28-
#include "lldb/Utility/DataBufferLLVM.h"
2928
#include "lldb/Utility/RegularExpression.h"
3029
#include "lldb/Utility/Stream.h"
3130
#include "lldb/lldb-enumerations.h"

lldb/source/Host/common/FileSystem.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "lldb/Host/FileSystem.h"
1010

11+
#include "lldb/Utility/DataBufferLLVM.h"
1112
#include "lldb/Utility/LLDBAssert.h"
1213
#include "lldb/Utility/TildeExpressionResolver.h"
1314

@@ -272,7 +273,7 @@ void FileSystem::Resolve(FileSpec &file_spec) {
272273
file_spec.SetIsResolved(true);
273274
}
274275

275-
std::shared_ptr<DataBufferLLVM>
276+
std::shared_ptr<DataBuffer>
276277
FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
277278
uint64_t offset) {
278279
const bool is_volatile = !IsLocal(path);
@@ -293,7 +294,7 @@ FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
293294
return std::shared_ptr<DataBufferLLVM>(new DataBufferLLVM(std::move(buffer)));
294295
}
295296

296-
std::shared_ptr<DataBufferLLVM>
297+
std::shared_ptr<DataBuffer>
297298
FileSystem::CreateDataBuffer(const FileSpec &file_spec, uint64_t size,
298299
uint64_t offset) {
299300
return CreateDataBuffer(file_spec.GetPath(), size, offset);

lldb/source/Host/common/Host.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include "lldb/Host/ProcessLauncher.h"
5757
#include "lldb/Host/ThreadLauncher.h"
5858
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
59-
#include "lldb/Utility/DataBufferLLVM.h"
6059
#include "lldb/Utility/FileSpec.h"
6160
#include "lldb/Utility/LLDBLog.h"
6261
#include "lldb/Utility/Log.h"
@@ -528,8 +527,9 @@ Status Host::RunShellCommand(llvm::StringRef shell_path, const Args &args,
528527
auto Buffer =
529528
FileSystem::Instance().CreateDataBuffer(output_file_spec);
530529
if (error.Success())
531-
command_output_ptr->assign(Buffer->GetChars(),
532-
Buffer->GetByteSize());
530+
command_output_ptr->assign(
531+
reinterpret_cast<char *>(Buffer->GetBytes()),
532+
Buffer->GetByteSize());
533533
}
534534
}
535535
}

0 commit comments

Comments
 (0)