[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
|
|
|
//===-- SBDeclaration.cpp -------------------------------------------------===//
|
2012-10-11 06:54:17 +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
|
2012-10-11 06:54:17 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBDeclaration.h"
|
2022-01-08 08:26:40 +08:00
|
|
|
#include "lldb/Utility/ReproducerInstrumentation.h"
|
2019-03-06 08:05:55 +08:00
|
|
|
#include "Utils.h"
|
2012-10-11 06:54:17 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2021-04-30 11:35:59 +08:00
|
|
|
#include "lldb/Core/Declaration.h"
|
2017-03-23 01:33:23 +08:00
|
|
|
#include "lldb/Host/PosixApi.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2012-10-11 06:54:17 +08:00
|
|
|
|
2021-05-26 18:19:37 +08:00
|
|
|
#include <climits>
|
2012-10-13 00:23:23 +08:00
|
|
|
|
2012-10-11 06:54:17 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2022-01-03 14:44:15 +08:00
|
|
|
SBDeclaration::SBDeclaration() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDeclaration);
|
|
|
|
}
|
2012-10-11 06:54:17 +08:00
|
|
|
|
2022-01-03 14:44:15 +08:00
|
|
|
SBDeclaration::SBDeclaration(const SBDeclaration &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBDeclaration, (const lldb::SBDeclaration &), rhs);
|
|
|
|
|
2019-03-06 08:05:55 +08:00
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2012-10-11 06:54:17 +08:00
|
|
|
}
|
|
|
|
|
2022-01-03 14:44:15 +08:00
|
|
|
SBDeclaration::SBDeclaration(const lldb_private::Declaration *lldb_object_ptr) {
|
2012-10-11 06:54:17 +08:00
|
|
|
if (lldb_object_ptr)
|
2019-08-15 06:19:23 +08:00
|
|
|
m_opaque_up = std::make_unique<Declaration>(*lldb_object_ptr);
|
2012-10-11 06:54:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const SBDeclaration &SBDeclaration::operator=(const SBDeclaration &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBDeclaration &,
|
|
|
|
SBDeclaration, operator=,(const lldb::SBDeclaration &),
|
|
|
|
rhs);
|
|
|
|
|
2019-03-06 08:05:55 +08:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2019-04-04 05:31:22 +08:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2012-10-11 06:54:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBDeclaration::SetDeclaration(
|
|
|
|
const lldb_private::Declaration &lldb_object_ref) {
|
|
|
|
ref() = lldb_object_ref;
|
|
|
|
}
|
|
|
|
|
2020-02-18 14:57:06 +08:00
|
|
|
SBDeclaration::~SBDeclaration() = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-11 06:54:17 +08:00
|
|
|
bool SBDeclaration::IsValid() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, 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();
|
|
|
|
}
|
|
|
|
SBDeclaration::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up.get() && m_opaque_up->IsValid();
|
2012-10-11 06:54:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBFileSpec SBDeclaration::GetFileSpec() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBDeclaration,
|
|
|
|
GetFileSpec);
|
|
|
|
|
2012-10-11 06:54:17 +08:00
|
|
|
|
|
|
|
SBFileSpec sb_file_spec;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up.get() && m_opaque_up->GetFile())
|
|
|
|
sb_file_spec.SetFileSpec(m_opaque_up->GetFile());
|
2012-10-11 06:54:17 +08:00
|
|
|
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_file_spec);
|
2012-10-11 06:54:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBDeclaration::GetLine() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetLine);
|
|
|
|
|
2012-10-11 06:54:17 +08:00
|
|
|
|
|
|
|
uint32_t line = 0;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
|
|
|
line = m_opaque_up->GetLine();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
|
|
|
|
2012-10-11 06:54:17 +08:00
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBDeclaration::GetColumn() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetColumn);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
|
|
|
return m_opaque_up->GetColumn();
|
2014-04-04 12:06:10 +08:00
|
|
|
return 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-11 06:54:17 +08:00
|
|
|
void SBDeclaration::SetFileSpec(lldb::SBFileSpec filespec) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBDeclaration, SetFileSpec, (lldb::SBFileSpec),
|
|
|
|
filespec);
|
|
|
|
|
2012-10-11 06:54:17 +08:00
|
|
|
if (filespec.IsValid())
|
|
|
|
ref().SetFile(filespec.ref());
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2012-10-11 06:54:17 +08:00
|
|
|
ref().SetFile(FileSpec());
|
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBDeclaration::SetLine(uint32_t line) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBDeclaration, SetLine, (uint32_t), line);
|
2012-10-11 06:54:17 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
ref().SetLine(line);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBDeclaration::SetColumn(uint32_t column) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBDeclaration, SetColumn, (uint32_t), column);
|
|
|
|
|
|
|
|
ref().SetColumn(column);
|
|
|
|
}
|
2012-10-11 06:54:17 +08:00
|
|
|
|
|
|
|
bool SBDeclaration::operator==(const SBDeclaration &rhs) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(
|
|
|
|
bool, SBDeclaration, operator==,(const lldb::SBDeclaration &), rhs);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
lldb_private::Declaration *lhs_ptr = m_opaque_up.get();
|
|
|
|
lldb_private::Declaration *rhs_ptr = rhs.m_opaque_up.get();
|
2012-10-11 06:54:17 +08:00
|
|
|
|
|
|
|
if (lhs_ptr && rhs_ptr)
|
|
|
|
return lldb_private::Declaration::Compare(*lhs_ptr, *rhs_ptr) == 0;
|
|
|
|
|
|
|
|
return lhs_ptr == rhs_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBDeclaration::operator!=(const SBDeclaration &rhs) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(
|
|
|
|
bool, SBDeclaration, operator!=,(const lldb::SBDeclaration &), rhs);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
lldb_private::Declaration *lhs_ptr = m_opaque_up.get();
|
|
|
|
lldb_private::Declaration *rhs_ptr = rhs.m_opaque_up.get();
|
2012-10-11 06:54:17 +08:00
|
|
|
|
|
|
|
if (lhs_ptr && rhs_ptr)
|
|
|
|
return lldb_private::Declaration::Compare(*lhs_ptr, *rhs_ptr) != 0;
|
|
|
|
|
|
|
|
return lhs_ptr != rhs_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::Declaration *SBDeclaration::operator->() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up.get();
|
2012-10-11 06:54:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::Declaration &SBDeclaration::ref() {
|
[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<lldb_private::Declaration>();
|
2019-02-13 14:25:41 +08:00
|
|
|
return *m_opaque_up;
|
2012-10-11 06:54:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::Declaration &SBDeclaration::ref() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
return *m_opaque_up;
|
2012-10-11 06:54:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBDeclaration::GetDescription(SBStream &description) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBDeclaration, GetDescription, (lldb::SBStream &),
|
|
|
|
description);
|
|
|
|
|
2012-10-11 06:54:17 +08:00
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up) {
|
2012-10-11 06:54:17 +08:00
|
|
|
char file_path[PATH_MAX * 2];
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->GetFile().GetPath(file_path, sizeof(file_path));
|
2012-10-11 06:54:17 +08:00
|
|
|
strm.Printf("%s:%u", file_path, GetLine());
|
|
|
|
if (GetColumn() > 0)
|
|
|
|
strm.Printf(":%u", GetColumn());
|
|
|
|
} else
|
|
|
|
strm.PutCString("No value");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
lldb_private::Declaration *SBDeclaration::get() { return m_opaque_up.get(); }
|