diff options
| author | Konrad Kleine <kkleine@redhat.com> | 2019-05-23 11:14:47 +0000 |
|---|---|---|
| committer | Konrad Kleine <kkleine@redhat.com> | 2019-05-23 11:14:47 +0000 |
| commit | 248a13057a4adbdb8d511b1458daf39d01a4b520 (patch) | |
| tree | 1209fb0822f0c14237eb9935e30da465014a6eda /lldb/source/Host | |
| parent | 32d976bac194d78656974e3e05bf52997a06f509 (diff) | |
| download | bcm5719-llvm-248a13057a4adbdb8d511b1458daf39d01a4b520.tar.gz bcm5719-llvm-248a13057a4adbdb8d511b1458daf39d01a4b520.zip | |
[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
Diffstat (limited to 'lldb/source/Host')
| -rw-r--r-- | lldb/source/Host/common/Editline.cpp | 14 | ||||
| -rw-r--r-- | lldb/source/Host/common/File.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Host/common/Host.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Host/common/HostNativeThreadBase.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Host/common/OptionParser.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Host/common/ProcessRunLock.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Host/common/SocketAddress.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Host/common/TCPSocket.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Host/common/TaskPool.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Host/common/Terminal.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Host/common/ThreadLauncher.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Host/common/XML.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Host/linux/Host.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Host/linux/HostInfoLinux.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Host/posix/HostThreadPosix.cpp | 2 |
16 files changed, 43 insertions, 40 deletions
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 2b647be572a..d3a70aeaa32 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -163,7 +163,7 @@ private: // Use static GetHistory() function to get a EditlineHistorySP to one of // these objects EditlineHistory(const std::string &prefix, uint32_t size, bool unique_entries) - : m_history(NULL), m_event(), m_prefix(prefix), m_path() { + : m_history(nullptr), m_event(), m_prefix(prefix), m_path() { m_history = history_winit(); history_w(m_history, &m_event, H_SETSIZE, size); if (unique_entries) @@ -202,7 +202,7 @@ public: if (m_history) { history_wend(m_history); - m_history = NULL; + m_history = nullptr; } } @@ -224,7 +224,7 @@ public: return history_sp; } - bool IsValid() const { return m_history != NULL; } + bool IsValid() const { return m_history != nullptr; } HistoryW *GetHistoryPtr() { return m_history; } @@ -514,11 +514,13 @@ int Editline::GetCharacter(EditLineGetCharType *c) { // Read returns, immediately lock the mutex again and check if we were // interrupted. m_output_mutex.unlock(); - int read_count = m_input_connection.Read(&ch, 1, llvm::None, status, NULL); + int read_count = + m_input_connection.Read(&ch, 1, llvm::None, status, nullptr); m_output_mutex.lock(); if (m_editor_status == EditorStatus::Interrupted) { while (read_count > 0 && status == lldb::eConnectionStatusSuccess) - read_count = m_input_connection.Read(&ch, 1, llvm::None, status, NULL); + read_count = + m_input_connection.Read(&ch, 1, llvm::None, status, nullptr); lldbassert(status == lldb::eConnectionStatusInterrupted); return 0; } @@ -1081,7 +1083,7 @@ void Editline::ConfigureEditor(bool multiline) { // Allow user-specific customization prior to registering bindings we // absolutely require - el_source(m_editline, NULL); + el_source(m_editline, nullptr); // Register an internal binding that external developers shouldn't use el_wset(m_editline, EL_ADDFN, EditLineConstString("lldb-revert-line"), diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index 85e625ca78f..c8c8d7a0d49 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -65,11 +65,11 @@ static const char *GetStreamOpenModeFromOptions(uint32_t options) { } else if (options & File::eOpenOptionWrite) { return "w"; } - return NULL; + return nullptr; } int File::kInvalidDescriptor = -1; -FILE *File::kInvalidStream = NULL; +FILE *File::kInvalidStream = nullptr; File::~File() { Close(); } @@ -634,9 +634,9 @@ size_t File::Printf(const char *format, ...) { size_t File::PrintfVarArg(const char *format, va_list args) { size_t result = 0; if (DescriptorIsValid()) { - char *s = NULL; + char *s = nullptr; result = vasprintf(&s, format, args); - if (s != NULL) { + if (s != nullptr) { if (result > 0) { size_t s_len = result; Write(s, s_len); diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index d3e41a2b044..be206406e93 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -112,7 +112,7 @@ HostThread Host::StartMonitoringChildProcess( ::snprintf(thread_name, sizeof(thread_name), "<lldb.host.wait4(pid=%" PRIu64 ")>", pid); return ThreadLauncher::LaunchThread( - thread_name, MonitorChildProcessThreadFunction, info_ptr, NULL); + thread_name, MonitorChildProcessThreadFunction, info_ptr, nullptr); } #ifndef __linux__ @@ -219,7 +219,7 @@ static thread_result_t MonitorChildProcessThreadFunction(void *arg) { bool exited = false; int signal = 0; int exit_status = 0; - const char *status_cstr = NULL; + const char *status_cstr = nullptr; if (WIFSTOPPED(status)) { signal = WSTOPSIG(status); status_cstr = "STOPPED"; @@ -282,7 +282,7 @@ static thread_result_t MonitorChildProcessThreadFunction(void *arg) { if (log) log->Printf("%s (arg = %p) thread exiting...", __FUNCTION__, arg); - return NULL; + return nullptr; } #endif // #if !defined (__APPLE__) && !defined (_WIN32) @@ -393,7 +393,7 @@ const char *Host::GetSignalAsCString(int signo) { default: break; } - return NULL; + return nullptr; } #endif diff --git a/lldb/source/Host/common/HostNativeThreadBase.cpp b/lldb/source/Host/common/HostNativeThreadBase.cpp index a5f876a7232..82f519e14f1 100644 --- a/lldb/source/Host/common/HostNativeThreadBase.cpp +++ b/lldb/source/Host/common/HostNativeThreadBase.cpp @@ -18,10 +18,10 @@ using namespace lldb; using namespace lldb_private; HostNativeThreadBase::HostNativeThreadBase() - : m_thread(LLDB_INVALID_HOST_THREAD), m_result(0) {} + : m_thread(LLDB_INVALID_HOST_THREAD), m_result(nullptr) {} HostNativeThreadBase::HostNativeThreadBase(thread_t thread) - : m_thread(thread), m_result(0) {} + : m_thread(thread), m_result(nullptr) {} lldb::thread_t HostNativeThreadBase::GetSystemHandle() const { return m_thread; @@ -37,7 +37,7 @@ bool HostNativeThreadBase::IsJoinable() const { void HostNativeThreadBase::Reset() { m_thread = LLDB_INVALID_HOST_THREAD; - m_result = 0; + m_result = nullptr; } bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const { @@ -47,7 +47,7 @@ bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const { lldb::thread_t HostNativeThreadBase::Release() { lldb::thread_t result = m_thread; m_thread = LLDB_INVALID_HOST_THREAD; - m_result = 0; + m_result = nullptr; return result; } diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp index 97704988d36..92ff6f63d95 100644 --- a/lldb/source/Host/common/OptionParser.cpp +++ b/lldb/source/Host/common/OptionParser.cpp @@ -55,11 +55,11 @@ std::string OptionParser::GetShortOptionString(struct option *long_options) { int i = 0; bool done = false; while (!done) { - if (long_options[i].name == 0 && long_options[i].has_arg == 0 && - long_options[i].flag == 0 && long_options[i].val == 0) { + if (long_options[i].name == nullptr && long_options[i].has_arg == 0 && + long_options[i].flag == nullptr && long_options[i].val == 0) { done = true; } else { - if (long_options[i].flag == NULL && isalpha(long_options[i].val)) { + if (long_options[i].flag == nullptr && isalpha(long_options[i].val)) { s.append(1, (char)long_options[i].val); switch (long_options[i].has_arg) { default: diff --git a/lldb/source/Host/common/ProcessRunLock.cpp b/lldb/source/Host/common/ProcessRunLock.cpp index 65a5dcca31f..a931da71876 100644 --- a/lldb/source/Host/common/ProcessRunLock.cpp +++ b/lldb/source/Host/common/ProcessRunLock.cpp @@ -12,7 +12,7 @@ namespace lldb_private { ProcessRunLock::ProcessRunLock() : m_running(false) { - int err = ::pthread_rwlock_init(&m_rwlock, NULL); + int err = ::pthread_rwlock_init(&m_rwlock, nullptr); (void)err; } diff --git a/lldb/source/Host/common/SocketAddress.cpp b/lldb/source/Host/common/SocketAddress.cpp index 06171d49bf6..882fd24558f 100644 --- a/lldb/source/Host/common/SocketAddress.cpp +++ b/lldb/source/Host/common/SocketAddress.cpp @@ -236,11 +236,11 @@ SocketAddress::GetAddressInfo(const char *hostname, const char *servname, hints.ai_protocol = ai_protocol; hints.ai_flags = ai_flags; - struct addrinfo *service_info_list = NULL; + struct addrinfo *service_info_list = nullptr; int err = ::getaddrinfo(hostname, servname, &hints, &service_info_list); if (err == 0 && service_info_list) { - for (struct addrinfo *service_ptr = service_info_list; service_ptr != NULL; - service_ptr = service_ptr->ai_next) { + for (struct addrinfo *service_ptr = service_info_list; + service_ptr != nullptr; service_ptr = service_ptr->ai_next) { addr_list.emplace_back(SocketAddress(service_ptr)); } } diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index 3f11e4e3b49..f97ca9eb55b 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/source/Host/common/TCPSocket.cpp @@ -143,7 +143,7 @@ Status TCPSocket::Connect(llvm::StringRef name) { return error; auto addresses = lldb_private::SocketAddress::GetAddressInfo( - host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); + host_str.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); for (auto address : addresses) { error = CreateSocket(address.GetFamily()); if (error.Fail()) @@ -182,7 +182,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { if (host_str == "*") host_str = "0.0.0.0"; auto addresses = lldb_private::SocketAddress::GetAddressInfo( - host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); + host_str.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); for (auto address : addresses) { int fd = Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, m_child_processes_inherit, error); diff --git a/lldb/source/Host/common/TaskPool.cpp b/lldb/source/Host/common/TaskPool.cpp index 062fa4abd06..d63d9f35d1e 100644 --- a/lldb/source/Host/common/TaskPool.cpp +++ b/lldb/source/Host/common/TaskPool.cpp @@ -73,7 +73,7 @@ void TaskPoolImpl::AddTask(std::function<void()> &&task_fn) { lldb::thread_result_t TaskPoolImpl::WorkerPtr(void *pool) { Worker((TaskPoolImpl *)pool); - return 0; + return nullptr; } void TaskPoolImpl::Worker(TaskPoolImpl *pool) { diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp index 9c60f0d1190..4b536b03d85 100644 --- a/lldb/source/Host/common/Terminal.cpp +++ b/lldb/source/Host/common/Terminal.cpp @@ -112,7 +112,7 @@ bool TerminalState::Save(int fd, bool save_process_group) { m_tflags = ::fcntl(fd, F_GETFL, 0); #endif #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED - if (m_termios_up == NULL) + if (m_termios_up == nullptr) m_termios_up.reset(new struct termios); int err = ::tcgetattr(fd, m_termios_up.get()); if (err != 0) @@ -151,7 +151,7 @@ bool TerminalState::Restore() const { if (ProcessGroupIsValid()) { // Save the original signal handler. - void (*saved_sigttou_callback)(int) = NULL; + void (*saved_sigttou_callback)(int) = nullptr; saved_sigttou_callback = (void (*)(int))signal(SIGTTOU, SIG_IGN); // Set the process group tcsetpgrp(fd, m_process_group); @@ -177,7 +177,7 @@ bool TerminalState::TFlagsIsValid() const { return m_tflags != -1; } // Returns true if m_ttystate is valid bool TerminalState::TTYStateIsValid() const { #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED - return m_termios_up != 0; + return m_termios_up != nullptr; #else return false; #endif diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp index ede864db108..2eff981bfa8 100644 --- a/lldb/source/Host/common/ThreadLauncher.cpp +++ b/lldb/source/Host/common/ThreadLauncher.cpp @@ -49,7 +49,7 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name, } #endif - pthread_attr_t *thread_attr_ptr = NULL; + pthread_attr_t *thread_attr_ptr = nullptr; pthread_attr_t thread_attr; bool destroy_attr = false; if (min_stack_byte_size > 0) { diff --git a/lldb/source/Host/common/XML.cpp b/lldb/source/Host/common/XML.cpp index 006b49f4e10..cb23ac17ef5 100644 --- a/lldb/source/Host/common/XML.cpp +++ b/lldb/source/Host/common/XML.cpp @@ -134,7 +134,7 @@ XMLNode XMLNode::GetChild() const { llvm::StringRef XMLNode::GetAttributeValue(const char *name, const char *fail_value) const { - const char *attr_value = NULL; + const char *attr_value = nullptr; #if defined(LIBXML2_DEFINED) if (IsValid()) diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index 03fa798f0f5..f6a8766a71c 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -216,12 +216,12 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info, DIR *dirproc = opendir(procdir); if (dirproc) { - struct dirent *direntry = NULL; + struct dirent *direntry = nullptr; const uid_t our_uid = getuid(); const lldb::pid_t our_pid = getpid(); bool all_users = match_info.GetMatchAllUsers(); - while ((direntry = readdir(dirproc)) != NULL) { + while ((direntry = readdir(dirproc)) != nullptr) { if (direntry->d_type != DT_DIR || !IsDirNumeric(direntry->d_name)) continue; @@ -269,8 +269,8 @@ bool Host::FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach) { DIR *dirproc = opendir(process_task_dir.c_str()); if (dirproc) { - struct dirent *direntry = NULL; - while ((direntry = readdir(dirproc)) != NULL) { + struct dirent *direntry = nullptr; + while ((direntry = readdir(dirproc)) != nullptr) { if (direntry->d_type != DT_DIR || !IsDirNumeric(direntry->d_name)) continue; diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp index 2b2207e7afa..78dd77b61fa 100644 --- a/lldb/source/Host/linux/HostInfoLinux.cpp +++ b/lldb/source/Host/linux/HostInfoLinux.cpp @@ -121,7 +121,8 @@ llvm::StringRef HostInfoLinux::GetDistributionId() { // retrieve the distribution id string. char distribution_id[256] = {'\0'}; - if (fgets(distribution_id, sizeof(distribution_id) - 1, file) != NULL) { + if (fgets(distribution_id, sizeof(distribution_id) - 1, file) != + nullptr) { if (log) log->Printf("distribution id command returned \"%s\"", distribution_id); diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 4bbebd627d4..167569dca69 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -111,7 +111,7 @@ ConnectionFileDescriptor::~ConnectionFileDescriptor() { if (log) log->Printf("%p ConnectionFileDescriptor::~ConnectionFileDescriptor ()", static_cast<void *>(this)); - Disconnect(NULL); + Disconnect(nullptr); CloseCommandPipe(); } diff --git a/lldb/source/Host/posix/HostThreadPosix.cpp b/lldb/source/Host/posix/HostThreadPosix.cpp index caa137ae3d0..d78bba517f6 100644 --- a/lldb/source/Host/posix/HostThreadPosix.cpp +++ b/lldb/source/Host/posix/HostThreadPosix.cpp @@ -29,7 +29,7 @@ Status HostThreadPosix::Join(lldb::thread_result_t *result) { error.SetError(err, lldb::eErrorTypePOSIX); } else { if (result) - *result = NULL; + *result = nullptr; error.SetError(EINVAL, eErrorTypePOSIX); } |

