[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
|
|
|
//===-- SBThreadCollection.cpp --------------------------------------------===//
|
2014-09-06 09:21:19 +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
|
2014-09-06 09:21:19 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBThreadCollection.h"
|
|
|
|
#include "lldb/API/SBThread.h"
|
|
|
|
#include "lldb/Target/ThreadList.h"
|
2022-01-20 03:38:26 +08:00
|
|
|
#include "lldb/Utility/Instrumentation.h"
|
2014-09-06 09:21:19 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2022-01-20 03:38:26 +08:00
|
|
|
SBThreadCollection::SBThreadCollection() { LLDB_INSTRUMENT_VA(this); }
|
2014-09-06 09:21:19 +08:00
|
|
|
|
|
|
|
SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_sp(rhs.m_opaque_sp) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, rhs);
|
2019-03-06 08:06:00 +08:00
|
|
|
}
|
2014-09-06 09:21:19 +08:00
|
|
|
|
|
|
|
const SBThreadCollection &SBThreadCollection::
|
|
|
|
operator=(const SBThreadCollection &rhs) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, rhs);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2014-09-06 09:21:19 +08:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
2022-01-10 14:54:08 +08:00
|
|
|
return *this;
|
2014-09-06 09:21:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads)
|
|
|
|
: m_opaque_sp(threads) {}
|
|
|
|
|
2020-02-18 14:57:06 +08:00
|
|
|
SBThreadCollection::~SBThreadCollection() = default;
|
2014-09-06 09:21:19 +08:00
|
|
|
|
|
|
|
void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) {
|
|
|
|
m_opaque_sp = threads;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::ThreadCollection *SBThreadCollection::get() const {
|
|
|
|
return m_opaque_sp.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::ThreadCollection *SBThreadCollection::operator->() const {
|
|
|
|
return m_opaque_sp.operator->();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ThreadCollectionSP &SBThreadCollection::operator*() {
|
|
|
|
return m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const {
|
|
|
|
return m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
bool SBThreadCollection::IsValid() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
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();
|
|
|
|
}
|
|
|
|
SBThreadCollection::operator bool() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
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_sp.get() != nullptr;
|
2019-03-06 08:06:00 +08:00
|
|
|
}
|
2014-09-06 09:21:19 +08:00
|
|
|
|
|
|
|
size_t SBThreadCollection::GetSize() {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2014-09-06 09:21:19 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetSize();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, idx);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2014-09-06 09:21:19 +08:00
|
|
|
SBThread thread;
|
|
|
|
if (m_opaque_sp && idx < m_opaque_sp->GetSize())
|
|
|
|
thread = m_opaque_sp->GetThreadAtIndex(idx);
|
2022-01-10 14:54:08 +08:00
|
|
|
return thread;
|
2014-09-06 09:21:19 +08:00
|
|
|
}
|