Skip to content

Commit 248a130

Browse files
committed
[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
1 parent 32d976b commit 248a130

File tree

250 files changed

+1487
-1461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+1487
-1461
lines changed

lldb/include/lldb/Breakpoint/BreakpointResolver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class BreakpointResolver : public Searcher {
209209
const char *) = delete;
210210

211211
lldb::BreakpointLocationSP AddLocation(Address loc_addr,
212-
bool *new_location = NULL);
212+
bool *new_location = nullptr);
213213

214214
Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
215215
lldb::addr_t m_offset; // A random offset the user asked us to add to any

lldb/source/API/SBAddress.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ bool SBAddress::IsValid() const {
8383
SBAddress::operator bool() const {
8484
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, operator bool);
8585

86-
return m_opaque_up != NULL && m_opaque_up->IsValid();
86+
return m_opaque_up != nullptr && m_opaque_up->IsValid();
8787
}
8888

8989
void SBAddress::Clear() {
@@ -186,7 +186,7 @@ Address *SBAddress::operator->() { return m_opaque_up.get(); }
186186
const Address *SBAddress::operator->() const { return m_opaque_up.get(); }
187187

188188
Address &SBAddress::ref() {
189-
if (m_opaque_up == NULL)
189+
if (m_opaque_up == nullptr)
190190
m_opaque_up.reset(new Address());
191191
return *m_opaque_up;
192192
}
@@ -208,7 +208,7 @@ bool SBAddress::GetDescription(SBStream &description) {
208208
// case there isn't one already...
209209
Stream &strm = description.ref();
210210
if (m_opaque_up->IsValid()) {
211-
m_opaque_up->Dump(&strm, NULL, Address::DumpStyleResolvedDescription,
211+
m_opaque_up->Dump(&strm, nullptr, Address::DumpStyleResolvedDescription,
212212
Address::DumpStyleModuleWithFileAddress, 4);
213213
StreamString sstrm;
214214
// m_opaque_up->Dump (&sstrm, NULL,

lldb/source/API/SBBlock.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
using namespace lldb;
2626
using namespace lldb_private;
2727

28-
SBBlock::SBBlock() : m_opaque_ptr(NULL) {
28+
SBBlock::SBBlock() : m_opaque_ptr(nullptr) {
2929
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBlock);
3030
}
3131

@@ -44,7 +44,7 @@ const SBBlock &SBBlock::operator=(const SBBlock &rhs) {
4444
return LLDB_RECORD_RESULT(*this);
4545
}
4646

47-
SBBlock::~SBBlock() { m_opaque_ptr = NULL; }
47+
SBBlock::~SBBlock() { m_opaque_ptr = nullptr; }
4848

4949
bool SBBlock::IsValid() const {
5050
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsValid);
@@ -53,14 +53,14 @@ bool SBBlock::IsValid() const {
5353
SBBlock::operator bool() const {
5454
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, operator bool);
5555

56-
return m_opaque_ptr != NULL;
56+
return m_opaque_ptr != nullptr;
5757
}
5858

5959
bool SBBlock::IsInlined() const {
6060
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsInlined);
6161

6262
if (m_opaque_ptr)
63-
return m_opaque_ptr->GetInlinedFunctionInfo() != NULL;
63+
return m_opaque_ptr->GetInlinedFunctionInfo() != nullptr;
6464
return false;
6565
}
6666

@@ -77,10 +77,10 @@ const char *SBBlock::GetInlinedName() const {
7777
language = function->GetLanguage();
7878
else
7979
language = lldb::eLanguageTypeUnknown;
80-
return inlined_info->GetName(language).AsCString(NULL);
80+
return inlined_info->GetName(language).AsCString(nullptr);
8181
}
8282
}
83-
return NULL;
83+
return nullptr;
8484
}
8585

8686
SBFileSpec SBBlock::GetInlinedCallSiteFile() const {

lldb/source/API/SBBreakpointLocation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const char *SBBreakpointLocation::GetCondition() {
179179
loc_sp->GetTarget().GetAPIMutex());
180180
return loc_sp->GetConditionText();
181181
}
182-
return NULL;
182+
return nullptr;
183183
}
184184

185185
void SBBreakpointLocation::SetAutoContinue(bool auto_continue) {
@@ -357,7 +357,7 @@ const char *SBBreakpointLocation::GetThreadName() const {
357357
loc_sp->GetTarget().GetAPIMutex());
358358
return loc_sp->GetThreadName();
359359
}
360-
return NULL;
360+
return nullptr;
361361
}
362362

363363
void SBBreakpointLocation::SetQueueName(const char *queue_name) {
@@ -382,7 +382,7 @@ const char *SBBreakpointLocation::GetQueueName() const {
382382
loc_sp->GetTarget().GetAPIMutex());
383383
loc_sp->GetQueueName();
384384
}
385-
return NULL;
385+
return nullptr;
386386
}
387387

388388
bool SBBreakpointLocation::IsResolved() {

lldb/source/API/SBBroadcaster.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@
1616
using namespace lldb;
1717
using namespace lldb_private;
1818

19-
SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(NULL) {
19+
SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(nullptr) {
2020
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBroadcaster);
2121
}
2222

2323
SBBroadcaster::SBBroadcaster(const char *name)
24-
: m_opaque_sp(new Broadcaster(NULL, name)), m_opaque_ptr(NULL) {
24+
: m_opaque_sp(new Broadcaster(nullptr, name)), m_opaque_ptr(nullptr) {
2525
LLDB_RECORD_CONSTRUCTOR(SBBroadcaster, (const char *), name);
2626

2727
m_opaque_ptr = m_opaque_sp.get();
2828
}
2929

3030
SBBroadcaster::SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns)
31-
: m_opaque_sp(owns ? broadcaster : NULL), m_opaque_ptr(broadcaster) {
32-
}
31+
: m_opaque_sp(owns ? broadcaster : nullptr), m_opaque_ptr(broadcaster) {}
3332

3433
SBBroadcaster::SBBroadcaster(const SBBroadcaster &rhs)
3534
: m_opaque_sp(rhs.m_opaque_sp), m_opaque_ptr(rhs.m_opaque_ptr) {
@@ -48,13 +47,13 @@ const SBBroadcaster &SBBroadcaster::operator=(const SBBroadcaster &rhs) {
4847
return LLDB_RECORD_RESULT(*this);
4948
}
5049

51-
SBBroadcaster::~SBBroadcaster() { reset(NULL, false); }
50+
SBBroadcaster::~SBBroadcaster() { reset(nullptr, false); }
5251

5352
void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) {
5453
LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEventByType,
5554
(uint32_t, bool), event_type, unique);
5655

57-
if (m_opaque_ptr == NULL)
56+
if (m_opaque_ptr == nullptr)
5857
return;
5958

6059
if (unique)
@@ -67,7 +66,7 @@ void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) {
6766
LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEvent,
6867
(const lldb::SBEvent &, bool), event, unique);
6968

70-
if (m_opaque_ptr == NULL)
69+
if (m_opaque_ptr == nullptr)
7170
return;
7271

7372
EventSP event_sp = event.GetSP();
@@ -104,7 +103,7 @@ const char *SBBroadcaster::GetName() const {
104103

105104
if (m_opaque_ptr)
106105
return m_opaque_ptr->GetBroadcasterName().GetCString();
107-
return NULL;
106+
return nullptr;
108107
}
109108

110109
bool SBBroadcaster::EventTypeHasListeners(uint32_t event_type) {
@@ -144,14 +143,14 @@ bool SBBroadcaster::IsValid() const {
144143
SBBroadcaster::operator bool() const {
145144
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBroadcaster, operator bool);
146145

147-
return m_opaque_ptr != NULL;
146+
return m_opaque_ptr != nullptr;
148147
}
149148

150149
void SBBroadcaster::Clear() {
151150
LLDB_RECORD_METHOD_NO_ARGS(void, SBBroadcaster, Clear);
152151

153152
m_opaque_sp.reset();
154-
m_opaque_ptr = NULL;
153+
m_opaque_ptr = nullptr;
155154
}
156155

157156
bool SBBroadcaster::operator==(const SBBroadcaster &rhs) const {

lldb/source/API/SBCommunication.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using namespace lldb;
1717
using namespace lldb_private;
1818

19-
SBCommunication::SBCommunication() : m_opaque(NULL), m_opaque_owned(false) {
19+
SBCommunication::SBCommunication() : m_opaque(nullptr), m_opaque_owned(false) {
2020
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommunication);
2121
}
2222

@@ -28,7 +28,7 @@ SBCommunication::SBCommunication(const char *broadcaster_name)
2828
SBCommunication::~SBCommunication() {
2929
if (m_opaque && m_opaque_owned)
3030
delete m_opaque;
31-
m_opaque = NULL;
31+
m_opaque = nullptr;
3232
m_opaque_owned = false;
3333
}
3434

@@ -39,7 +39,7 @@ bool SBCommunication::IsValid() const {
3939
SBCommunication::operator bool() const {
4040
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, operator bool);
4141

42-
return m_opaque != NULL;
42+
return m_opaque != nullptr;
4343
}
4444

4545
bool SBCommunication::GetCloseOnEOF() {
@@ -64,7 +64,7 @@ ConnectionStatus SBCommunication::Connect(const char *url) {
6464
if (m_opaque) {
6565
if (!m_opaque->HasConnection())
6666
m_opaque->SetConnection(Host::CreateDefaultConnection(url).release());
67-
return m_opaque->Connect(url, NULL);
67+
return m_opaque->Connect(url, nullptr);
6868
}
6969
return eConnectionStatusNoConnection;
7070
}
@@ -115,7 +115,7 @@ size_t SBCommunication::Read(void *dst, size_t dst_len, uint32_t timeout_usec,
115115
? Timeout<std::micro>(llvm::None)
116116
: std::chrono::microseconds(timeout_usec);
117117
if (m_opaque)
118-
bytes_read = m_opaque->Read(dst, dst_len, timeout, status, NULL);
118+
bytes_read = m_opaque->Read(dst, dst_len, timeout, status, nullptr);
119119
else
120120
status = eConnectionStatusNoConnection;
121121

@@ -130,7 +130,7 @@ size_t SBCommunication::Write(const void *src, size_t src_len,
130130

131131
size_t bytes_written = 0;
132132
if (m_opaque)
133-
bytes_written = m_opaque->Write(src, src_len, status, NULL);
133+
bytes_written = m_opaque->Write(src, src_len, status, nullptr);
134134
else
135135
status = eConnectionStatusNoConnection;
136136

lldb/source/API/SBCompileUnit.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using namespace lldb;
2121
using namespace lldb_private;
2222

23-
SBCompileUnit::SBCompileUnit() : m_opaque_ptr(NULL) {
23+
SBCompileUnit::SBCompileUnit() : m_opaque_ptr(nullptr) {
2424
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCompileUnit);
2525
}
2626

@@ -41,7 +41,7 @@ const SBCompileUnit &SBCompileUnit::operator=(const SBCompileUnit &rhs) {
4141
return LLDB_RECORD_RESULT(*this);
4242
}
4343

44-
SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = NULL; }
44+
SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = nullptr; }
4545

4646
SBFileSpec SBCompileUnit::GetFileSpec() const {
4747
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBCompileUnit,
@@ -108,8 +108,8 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
108108
file_spec = *m_opaque_ptr;
109109

110110
index = m_opaque_ptr->FindLineEntry(
111-
start_idx, line, inline_file_spec ? inline_file_spec->get() : NULL,
112-
exact, NULL);
111+
start_idx, line, inline_file_spec ? inline_file_spec->get() : nullptr,
112+
exact, nullptr);
113113
}
114114

115115
return index;
@@ -193,7 +193,7 @@ bool SBCompileUnit::IsValid() const {
193193
SBCompileUnit::operator bool() const {
194194
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCompileUnit, operator bool);
195195

196-
return m_opaque_ptr != NULL;
196+
return m_opaque_ptr != nullptr;
197197
}
198198

199199
bool SBCompileUnit::operator==(const SBCompileUnit &rhs) const {

lldb/source/API/SBData.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool SBData::IsValid() {
6464
SBData::operator bool() const {
6565
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBData, operator bool);
6666

67-
return m_opaque_sp.get() != NULL;
67+
return m_opaque_sp.get() != nullptr;
6868
}
6969

7070
uint8_t SBData::GetAddressByteSize() {
@@ -312,13 +312,13 @@ const char *SBData::GetString(lldb::SBError &error, lldb::offset_t offset) {
312312
LLDB_RECORD_METHOD(const char *, SBData, GetString,
313313
(lldb::SBError &, lldb::offset_t), error, offset);
314314

315-
const char *value = 0;
315+
const char *value = nullptr;
316316
if (!m_opaque_sp.get()) {
317317
error.SetErrorString("no value to read from");
318318
} else {
319319
uint32_t old_offset = offset;
320320
value = m_opaque_sp->GetCStr(&offset);
321-
if (offset == old_offset || (value == NULL))
321+
if (offset == old_offset || (value == nullptr))
322322
error.SetErrorString("unable to read data");
323323
}
324324
return value;
@@ -346,13 +346,13 @@ size_t SBData::ReadRawData(lldb::SBError &error, lldb::offset_t offset,
346346
(lldb::SBError &, lldb::offset_t, void *, size_t), error,
347347
offset, buf, size);
348348

349-
void *ok = NULL;
349+
void *ok = nullptr;
350350
if (!m_opaque_sp.get()) {
351351
error.SetErrorString("no value to read from");
352352
} else {
353353
uint32_t old_offset = offset;
354354
ok = m_opaque_sp->GetU8(&offset, buf, size);
355-
if ((offset == old_offset) || (ok == NULL))
355+
if ((offset == old_offset) || (ok == nullptr))
356356
error.SetErrorString("unable to read data");
357357
}
358358
return ok ? size : 0;

lldb/source/API/SBDeclaration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const lldb_private::Declaration *SBDeclaration::operator->() const {
147147
}
148148

149149
lldb_private::Declaration &SBDeclaration::ref() {
150-
if (m_opaque_up == NULL)
150+
if (m_opaque_up == nullptr)
151151
m_opaque_up.reset(new lldb_private::Declaration());
152152
return *m_opaque_up;
153153
}

lldb/source/API/SBError.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const char *SBError::GetCString() const {
4141

4242
if (m_opaque_up)
4343
return m_opaque_up->AsCString();
44-
return NULL;
44+
return nullptr;
4545
}
4646

4747
void SBError::Clear() {
@@ -144,11 +144,11 @@ bool SBError::IsValid() const {
144144
SBError::operator bool() const {
145145
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, operator bool);
146146

147-
return m_opaque_up != NULL;
147+
return m_opaque_up != nullptr;
148148
}
149149

150150
void SBError::CreateIfNeeded() {
151-
if (m_opaque_up == NULL)
151+
if (m_opaque_up == nullptr)
152152
m_opaque_up.reset(new Status());
153153
}
154154

@@ -175,7 +175,8 @@ bool SBError::GetDescription(SBStream &description) {
175175
description.Printf("success");
176176
else {
177177
const char *err_string = GetCString();
178-
description.Printf("error: %s", (err_string != NULL ? err_string : ""));
178+
description.Printf("error: %s",
179+
(err_string != nullptr ? err_string : ""));
179180
}
180181
} else
181182
description.Printf("error: <NULL>");

lldb/source/API/SBEvent.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
using namespace lldb;
2323
using namespace lldb_private;
2424

25-
SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(NULL) {
25+
SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(nullptr) {
2626
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEvent);
2727
}
2828

@@ -69,7 +69,7 @@ const char *SBEvent::GetDataFlavor() {
6969
if (event_data)
7070
return lldb_event->GetData()->GetFlavor().AsCString();
7171
}
72-
return NULL;
72+
return nullptr;
7373
}
7474

7575
uint32_t SBEvent::GetType() const {
@@ -168,7 +168,7 @@ SBEvent::operator bool() const {
168168

169169
// Do NOT use m_opaque_ptr directly!!! Must use the SBEvent::get() accessor.
170170
// See comments in SBEvent::get()....
171-
return SBEvent::get() != NULL;
171+
return SBEvent::get() != nullptr;
172172
}
173173

174174
const char *SBEvent::GetCStringFromEvent(const SBEvent &event) {

0 commit comments

Comments
 (0)