[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
|
|
|
//===-- SBLineEntry.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/SBLineEntry.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2019-03-06 08:05:55 +08:00
|
|
|
#include "Utils.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2017-03-23 01:33:23 +08:00
|
|
|
#include "lldb/Host/PosixApi.h"
|
2010-10-31 11:01:06 +08:00
|
|
|
#include "lldb/Symbol/LineEntry.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2021-05-26 18:19:37 +08:00
|
|
|
#include <climits>
|
2019-03-06 08:05:55 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
2010-10-26 11:11:13 +08:00
|
|
|
using namespace lldb_private;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBLineEntry::SBLineEntry() : m_opaque_up() {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBLineEntry);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
SBLineEntry::SBLineEntry(const SBLineEntry &rhs) : m_opaque_up() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBLineEntry, (const lldb::SBLineEntry &), rhs);
|
|
|
|
|
2019-03-06 08:05:55 +08:00
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBLineEntry::SBLineEntry(const lldb_private::LineEntry *lldb_object_ptr)
|
2019-02-13 14:25:41 +08:00
|
|
|
: m_opaque_up() {
|
2010-06-09 00:52:24 +08:00
|
|
|
if (lldb_object_ptr)
|
2019-08-15 06:19:23 +08:00
|
|
|
m_opaque_up = std::make_unique<LineEntry>(*lldb_object_ptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBLineEntry &,
|
|
|
|
SBLineEntry, operator=,(const lldb::SBLineEntry &), 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);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) {
|
2019-08-15 06:19:23 +08:00
|
|
|
m_opaque_up = std::make_unique<LineEntry>(lldb_object_ref);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2020-02-18 14:57:06 +08:00
|
|
|
SBLineEntry::~SBLineEntry() = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBAddress SBLineEntry::GetStartAddress() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry,
|
|
|
|
GetStartAddress);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBAddress sb_address;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
2020-09-26 02:15:44 +08:00
|
|
|
sb_address.SetAddress(m_opaque_up->range.GetBaseAddress());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_address);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBAddress SBLineEntry::GetEndAddress() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry, GetEndAddress);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBAddress sb_address;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up) {
|
2020-09-26 02:15:44 +08:00
|
|
|
sb_address.SetAddress(m_opaque_up->range.GetBaseAddress());
|
2019-02-13 14:25:41 +08:00
|
|
|
sb_address.OffsetAddress(m_opaque_up->range.GetByteSize());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_address);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBLineEntry::IsValid() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLineEntry, 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();
|
|
|
|
}
|
|
|
|
SBLineEntry::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLineEntry, 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();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
SBFileSpec SBLineEntry::GetFileSpec() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBLineEntry, GetFileSpec);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFileSpec sb_file_spec;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up.get() && m_opaque_up->file)
|
|
|
|
sb_file_spec.SetFileSpec(m_opaque_up->file);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_file_spec);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
uint32_t SBLineEntry::GetLine() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBLineEntry, GetLine);
|
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
uint32_t line = 0;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
|
|
|
line = m_opaque_up->line;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
return line;
|
2011-09-26 15:11:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBLineEntry::GetColumn() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBLineEntry, GetColumn);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up)
|
|
|
|
return m_opaque_up->column;
|
2010-06-09 00:52:24 +08:00
|
|
|
return 0;
|
2011-09-26 15:11:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec),
|
|
|
|
filespec);
|
|
|
|
|
2011-09-26 15:11:27 +08:00
|
|
|
if (filespec.IsValid())
|
|
|
|
ref().file = filespec.ref();
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2011-09-26 15:11:27 +08:00
|
|
|
ref().file.Clear();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBLineEntry::SetLine(uint32_t line) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBLineEntry, SetLine, (uint32_t), line);
|
|
|
|
|
|
|
|
ref().line = line;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBLineEntry::SetColumn(uint32_t column) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBLineEntry, SetColumn, (uint32_t), column);
|
2011-09-26 15:11:27 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
ref().line = column;
|
|
|
|
}
|
2011-09-26 15:11:27 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool SBLineEntry::operator==(const SBLineEntry &rhs) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(
|
|
|
|
bool, SBLineEntry, operator==,(const lldb::SBLineEntry &), rhs);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
lldb_private::LineEntry *lhs_ptr = m_opaque_up.get();
|
|
|
|
lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (lhs_ptr && rhs_ptr)
|
|
|
|
return lldb_private::LineEntry::Compare(*lhs_ptr, *rhs_ptr) == 0;
|
|
|
|
|
|
|
|
return lhs_ptr == rhs_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBLineEntry::operator!=(const SBLineEntry &rhs) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(
|
|
|
|
bool, SBLineEntry, operator!=,(const lldb::SBLineEntry &), rhs);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
lldb_private::LineEntry *lhs_ptr = m_opaque_up.get();
|
|
|
|
lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (lhs_ptr && rhs_ptr)
|
|
|
|
return lldb_private::LineEntry::Compare(*lhs_ptr, *rhs_ptr) != 0;
|
|
|
|
|
|
|
|
return lhs_ptr != rhs_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::LineEntry *SBLineEntry::operator->() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-26 15:11:27 +08:00
|
|
|
lldb_private::LineEntry &SBLineEntry::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::LineEntry>();
|
2019-02-13 14:25:41 +08:00
|
|
|
return *m_opaque_up;
|
2011-09-26 15:11:27 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_up; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool SBLineEntry::GetDescription(SBStream &description) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBLineEntry, GetDescription, (lldb::SBStream &),
|
|
|
|
description);
|
|
|
|
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up) {
|
2010-09-20 13:20:02 +08:00
|
|
|
char file_path[PATH_MAX * 2];
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->file.GetPath(file_path, sizeof(file_path));
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.Printf("%s:%u", file_path, GetLine());
|
2010-09-20 13:20:02 +08:00
|
|
|
if (GetColumn() > 0)
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.Printf(":%u", GetColumn());
|
2010-09-20 13:20:02 +08:00
|
|
|
} else
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.PutCString("No value");
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
return true;
|
|
|
|
}
|
2010-10-27 07:49:36 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
lldb_private::LineEntry *SBLineEntry::get() { return m_opaque_up.get(); }
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBLineEntry>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBLineEntry, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBLineEntry, (const lldb::SBLineEntry &));
|
|
|
|
LLDB_REGISTER_METHOD(const lldb::SBLineEntry &,
|
|
|
|
SBLineEntry, operator=,(const lldb::SBLineEntry &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBLineEntry, GetStartAddress,
|
|
|
|
());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBLineEntry, GetEndAddress, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBLineEntry, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBLineEntry, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBLineEntry, GetFileSpec, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint32_t, SBLineEntry, GetLine, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint32_t, SBLineEntry, GetColumn, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBLineEntry, SetLine, (uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBLineEntry, SetColumn, (uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(
|
|
|
|
bool, SBLineEntry, operator==,(const lldb::SBLineEntry &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(
|
|
|
|
bool, SBLineEntry, operator!=,(const lldb::SBLineEntry &));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBLineEntry, GetDescription, (lldb::SBStream &));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|