[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
|
|
|
//===-- DataBufferHeap.cpp ------------------------------------------------===//
|
2010-06-09 00:52:24 +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
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-03-04 09:30:05 +08:00
|
|
|
#include "lldb/Utility/DataBufferHeap.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-03-03 08:51:40 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
// Default constructor
|
|
|
|
DataBufferHeap::DataBufferHeap() : m_data() {}
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Initialize this class with "n" characters and fill the buffer with "ch".
|
2013-03-15 02:31:44 +08:00
|
|
|
DataBufferHeap::DataBufferHeap(lldb::offset_t n, uint8_t ch) : m_data() {
|
2013-07-25 02:17:35 +08:00
|
|
|
if (n < m_data.max_size())
|
|
|
|
m_data.assign(n, ch);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Initialize this class with a copy of the "n" bytes from the "bytes" buffer.
|
2013-03-15 02:31:44 +08:00
|
|
|
DataBufferHeap::DataBufferHeap(const void *src, lldb::offset_t src_len)
|
2010-06-09 00:52:24 +08:00
|
|
|
: m_data() {
|
|
|
|
CopyData(src, src_len);
|
|
|
|
}
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Virtual destructor since this class inherits from a pure virtual base class.
|
2016-03-03 08:51:40 +08:00
|
|
|
DataBufferHeap::~DataBufferHeap() = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Return a pointer to the bytes owned by this object, or nullptr if the object
|
|
|
|
// contains no bytes.
|
2010-06-09 00:52:24 +08:00
|
|
|
uint8_t *DataBufferHeap::GetBytes() {
|
2016-03-03 08:51:40 +08:00
|
|
|
return (m_data.empty() ? nullptr : m_data.data());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Return a const pointer to the bytes owned by this object, or nullptr if the
|
|
|
|
// object contains no bytes.
|
2010-06-09 00:52:24 +08:00
|
|
|
const uint8_t *DataBufferHeap::GetBytes() const {
|
2016-03-03 08:51:40 +08:00
|
|
|
return (m_data.empty() ? nullptr : m_data.data());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return the number of bytes this object currently contains.
|
|
|
|
uint64_t DataBufferHeap::GetByteSize() const { return m_data.size(); }
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Sets the number of bytes that this object should be able to contain. This
|
|
|
|
// can be used prior to copying data into the buffer.
|
2013-03-15 02:31:44 +08:00
|
|
|
uint64_t DataBufferHeap::SetByteSize(uint64_t new_size) {
|
2010-06-09 00:52:24 +08:00
|
|
|
m_data.resize(new_size);
|
|
|
|
return m_data.size();
|
|
|
|
}
|
|
|
|
|
2013-03-15 02:31:44 +08:00
|
|
|
void DataBufferHeap::CopyData(const void *src, uint64_t src_len) {
|
2019-05-23 13:12:11 +08:00
|
|
|
const uint8_t *src_u8 = static_cast<const uint8_t *>(src);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (src && src_len > 0)
|
|
|
|
m_data.assign(src_u8, src_u8 + src_len);
|
|
|
|
else
|
|
|
|
m_data.clear();
|
|
|
|
}
|
|
|
|
|
2014-07-12 08:24:33 +08:00
|
|
|
void DataBufferHeap::AppendData(const void *src, uint64_t src_len) {
|
2019-05-23 13:12:11 +08:00
|
|
|
m_data.insert(m_data.end(), static_cast<const uint8_t *>(src),
|
|
|
|
static_cast<const uint8_t *>(src) + src_len);
|
2014-07-12 08:24:33 +08:00
|
|
|
}
|
|
|
|
|
2013-07-12 06:46:58 +08:00
|
|
|
void DataBufferHeap::Clear() {
|
|
|
|
buffer_t empty;
|
|
|
|
m_data.swap(empty);
|
|
|
|
}
|