[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- DataBufferLLVM.cpp ------------------------------------------------===//
|
2017-02-25 02:56:49 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-02-25 02:56:49 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-03-04 09:30:05 +08:00
|
|
|
#include "lldb/Utility/DataBufferLLVM.h"
|
2017-02-25 02:56:49 +08:00
|
|
|
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
|
2021-05-26 18:19:37 +08:00
|
|
|
#include <cassert>
|
2017-04-07 02:12:24 +08:00
|
|
|
|
2017-02-25 02:56:49 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
|
2022-04-02 06:59:18 +08:00
|
|
|
DataBufferLLVM::DataBufferLLVM(std::unique_ptr<llvm::MemoryBuffer> MemBuffer)
|
2017-02-25 02:56:49 +08:00
|
|
|
: Buffer(std::move(MemBuffer)) {
|
|
|
|
assert(Buffer != nullptr &&
|
|
|
|
"Cannot construct a DataBufferLLVM with a null buffer");
|
|
|
|
}
|
|
|
|
|
2021-07-03 02:27:37 +08:00
|
|
|
DataBufferLLVM::~DataBufferLLVM() = default;
|
2017-02-25 02:56:49 +08:00
|
|
|
|
2022-04-02 06:59:18 +08:00
|
|
|
const uint8_t *DataBufferLLVM::GetBytesImpl() const {
|
|
|
|
return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::offset_t DataBufferLLVM::GetByteSize() const {
|
|
|
|
return Buffer->getBufferSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
WritableDataBufferLLVM::WritableDataBufferLLVM(
|
|
|
|
std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)
|
|
|
|
: Buffer(std::move(MemBuffer)) {
|
|
|
|
assert(Buffer != nullptr &&
|
|
|
|
"Cannot construct a WritableDataBufferLLVM with a null buffer");
|
2017-02-25 02:56:49 +08:00
|
|
|
}
|
|
|
|
|
2022-04-02 06:59:18 +08:00
|
|
|
WritableDataBufferLLVM::~WritableDataBufferLLVM() = default;
|
|
|
|
|
|
|
|
const uint8_t *WritableDataBufferLLVM::GetBytesImpl() const {
|
Make sure DataBufferLLVM contents are writable
Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.
This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.
This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.
Reviewers: zturner, clayborg, jingham
Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits
Differential Revision: https://reviews.llvm.org/D40079
llvm-svn: 321255
2017-12-21 18:54:30 +08:00
|
|
|
return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
|
|
|
|
}
|
2017-02-25 02:56:49 +08:00
|
|
|
|
2022-04-02 06:59:18 +08:00
|
|
|
lldb::offset_t WritableDataBufferLLVM::GetByteSize() const {
|
2017-02-25 02:56:49 +08:00
|
|
|
return Buffer->getBufferSize();
|
|
|
|
}
|
2022-04-02 06:59:18 +08:00
|
|
|
|
|
|
|
char DataBufferLLVM::ID;
|
|
|
|
char WritableDataBufferLLVM::ID;
|