[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
|
|
|
//===-- SBValueList.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
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBValueList.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBValue.h"
|
|
|
|
#include "lldb/Core/ValueObjectList.h"
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
class ValueListImpl {
|
|
|
|
public:
|
|
|
|
ValueListImpl() : m_values() {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
ValueListImpl(const ValueListImpl &rhs) : m_values(rhs.m_values) {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
ValueListImpl &operator=(const ValueListImpl &rhs) {
|
|
|
|
if (this == &rhs)
|
2013-02-08 02:23:56 +08:00
|
|
|
return *this;
|
2013-04-23 06:57:56 +08:00
|
|
|
m_values = rhs.m_values;
|
|
|
|
return *this;
|
2015-07-22 16:12:01 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
uint32_t GetSize() { return m_values.size(); }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
void Append(const lldb::SBValue &sb_value) { m_values.push_back(sb_value); }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
void Append(const ValueListImpl &list) {
|
|
|
|
for (auto val : list.m_values)
|
|
|
|
Append(val);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
lldb::SBValue GetValueAtIndex(uint32_t index) {
|
|
|
|
if (index >= GetSize())
|
2013-02-08 02:23:56 +08:00
|
|
|
return lldb::SBValue();
|
2013-04-23 06:57:56 +08:00
|
|
|
return m_values[index];
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
lldb::SBValue FindValueByUID(lldb::user_id_t uid) {
|
|
|
|
for (auto val : m_values) {
|
|
|
|
if (val.IsValid() && val.GetID() == uid)
|
|
|
|
return val;
|
|
|
|
}
|
2014-11-22 05:45:03 +08:00
|
|
|
return lldb::SBValue();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2014-11-22 06:23:08 +08:00
|
|
|
lldb::SBValue GetFirstValueByName(const char *name) const {
|
2014-11-22 05:45:03 +08:00
|
|
|
if (name) {
|
|
|
|
for (auto val : m_values) {
|
|
|
|
if (val.IsValid() && val.GetName() && strcmp(name, val.GetName()) == 0)
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
2013-04-23 06:57:56 +08:00
|
|
|
return lldb::SBValue();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-02-08 02:23:56 +08:00
|
|
|
|
2013-04-23 06:57:56 +08:00
|
|
|
private:
|
|
|
|
std::vector<lldb::SBValue> m_values;
|
|
|
|
};
|
2013-02-08 02:23:56 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBValueList::SBValueList() : m_opaque_up() {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBValueList);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_up() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &), rhs);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (rhs.IsValid())
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<ValueListImpl>(*rhs);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_up() {
|
2010-06-09 00:52:24 +08:00
|
|
|
if (lldb_object_ptr)
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<ValueListImpl>(*lldb_object_ptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2020-02-18 14:57:06 +08:00
|
|
|
SBValueList::~SBValueList() = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
bool SBValueList::IsValid() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, IsValid);
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 21:58:46 +08:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBValueList::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return (m_opaque_up != nullptr);
|
2019-03-06 08:06:00 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBValueList::Clear() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBValueList, Clear);
|
|
|
|
|
|
|
|
m_opaque_up.reset();
|
|
|
|
}
|
2011-12-20 04:39:44 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
const SBValueList &SBValueList::operator=(const SBValueList &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBValueList &,
|
|
|
|
SBValueList, operator=,(const lldb::SBValueList &), rhs);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (this != &rhs) {
|
|
|
|
if (rhs.IsValid())
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<ValueListImpl>(*rhs);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2019-04-04 05:31:22 +08:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
ValueListImpl *SBValueList::operator->() { return m_opaque_up.get(); }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
ValueListImpl &SBValueList::operator*() { return *m_opaque_up; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
const ValueListImpl *SBValueList::operator->() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
const ValueListImpl &SBValueList::operator*() const { return *m_opaque_up; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
void SBValueList::Append(const SBValue &val_obj) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBValueList, Append, (const lldb::SBValue &),
|
|
|
|
val_obj);
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
CreateIfNeeded();
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->Append(val_obj);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBValueList::Append(lldb::ValueObjectSP &val_obj_sp) {
|
|
|
|
if (val_obj_sp) {
|
|
|
|
CreateIfNeeded();
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->Append(SBValue(val_obj_sp));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
void SBValueList::Append(const lldb::SBValueList &value_list) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBValueList, Append, (const lldb::SBValueList &),
|
|
|
|
value_list);
|
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
if (value_list.IsValid()) {
|
|
|
|
CreateIfNeeded();
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->Append(*value_list);
|
2011-06-30 06:09:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValue SBValueList::GetValueAtIndex(uint32_t idx) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValueList, GetValueAtIndex,
|
|
|
|
(uint32_t), idx);
|
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-27 07:49:36 +08:00
|
|
|
SBValue sb_value;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
|
|
|
sb_value = m_opaque_up->GetValueAtIndex(idx);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_value);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBValueList::GetSize() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBValueList, GetSize);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t size = 0;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
|
|
|
size = m_opaque_up->GetSize();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBValueList::CreateIfNeeded() {
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
if (m_opaque_up == nullptr)
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<ValueListImpl>();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBValue, SBValueList, FindValueObjectByUID,
|
|
|
|
(lldb::user_id_t), uid);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValue sb_value;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
|
|
|
sb_value = m_opaque_up->FindValueByUID(uid);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_value);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2014-11-22 06:23:08 +08:00
|
|
|
SBValue SBValueList::GetFirstValueByName(const char *name) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValueList, GetFirstValueByName,
|
|
|
|
(const char *), name);
|
|
|
|
|
2014-11-22 05:45:03 +08:00
|
|
|
SBValue sb_value;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
|
|
|
sb_value = m_opaque_up->GetFirstValueByName(name);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_value);
|
2014-11-22 05:45:03 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
void *SBValueList::opaque_ptr() { return m_opaque_up.get(); }
|
2010-10-27 07:49:36 +08:00
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
ValueListImpl &SBValueList::ref() {
|
|
|
|
CreateIfNeeded();
|
2019-02-13 14:25:41 +08:00
|
|
|
return *m_opaque_up;
|
2011-06-30 06:09:02 +08:00
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBValueList>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBValueList, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBValueList, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBValueList, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBValueList, Clear, ());
|
|
|
|
LLDB_REGISTER_METHOD(const lldb::SBValueList &,
|
|
|
|
SBValueList, operator=,(const lldb::SBValueList &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBValueList, Append, (const lldb::SBValue &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBValueList, Append,
|
|
|
|
(const lldb::SBValueList &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValueList, GetValueAtIndex,
|
|
|
|
(uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint32_t, SBValueList, GetSize, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBValue, SBValueList, FindValueObjectByUID,
|
|
|
|
(lldb::user_id_t));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValueList, GetFirstValueByName,
|
|
|
|
(const char *));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|