[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
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index ee0897e..56d2581 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -126,7 +126,7 @@
   LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
                             (const lldb::SBEvent &), event);
 
-  return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL;
+  return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr;
 }
 
 SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) {
@@ -171,7 +171,7 @@
 SBTarget::operator bool() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool);
 
-  return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
+  return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid();
 }
 
 SBProcess SBTarget::GetProcess() {
@@ -288,9 +288,9 @@
                      (const char **, const char **, const char *), argv, envp,
                      working_directory);
 
-  char *stdin_path = NULL;
-  char *stdout_path = NULL;
-  char *stderr_path = NULL;
+  char *stdin_path = nullptr;
+  char *stdout_path = nullptr;
+  char *stderr_path = nullptr;
   uint32_t launch_flags = 0;
   bool stop_at_entry = false;
   SBError error;
@@ -307,7 +307,7 @@
   TargetSP target_sp(GetSP());
   if (target_sp) {
     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
-    sb_error.ref() = target_sp->Install(NULL);
+    sb_error.ref() = target_sp->Install(nullptr);
   }
   return LLDB_RECORD_RESULT(sb_error);
 }
@@ -381,7 +381,7 @@
     if (listener.IsValid())
       launch_info.SetListener(listener.GetSP());
 
-    error.SetError(target_sp->Launch(launch_info, NULL));
+    error.SetError(target_sp->Launch(launch_info, nullptr));
 
     sb_process.SetSP(target_sp->GetProcessSP());
   } else {
@@ -430,7 +430,7 @@
     if (arch_spec.IsValid())
       launch_info.GetArchitecture() = arch_spec;
 
-    error.SetError(target_sp->Launch(launch_info, NULL));
+    error.SetError(target_sp->Launch(launch_info, nullptr));
     sb_launch_info.set_ref(launch_info);
     sb_process.SetSP(target_sp->GetProcessSP());
   } else {
@@ -551,14 +551,14 @@
     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
     if (listener.IsValid())
       process_sp =
-          target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, NULL);
+          target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr);
     else
       process_sp = target_sp->CreateProcess(
-          target_sp->GetDebugger().GetListener(), plugin_name, NULL);
+          target_sp->GetDebugger().GetListener(), plugin_name, nullptr);
 
     if (process_sp) {
       sb_process.SetSP(process_sp);
-      error.SetError(process_sp->ConnectRemote(NULL, url));
+      error.SetError(process_sp->ConnectRemote(nullptr, url));
     } else {
       error.SetErrorString("unable to create lldb_private::Process");
     }
@@ -788,12 +788,12 @@
       FileSpecList module_spec_list;
       module_spec_list.Append(FileSpec(module_name));
       sb_bp = target_sp->CreateBreakpoint(
-          &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
+          &module_spec_list, nullptr, symbol_name, eFunctionNameTypeAuto,
           eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
     } else {
       sb_bp = target_sp->CreateBreakpoint(
-          NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown,
-          offset, skip_prologue, internal, hardware);
+          nullptr, nullptr, symbol_name, eFunctionNameTypeAuto,
+          eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
     }
   }
 
@@ -1425,7 +1425,7 @@
     // Target::CreateWatchpoint() is thread safe.
     Status cw_error;
     // This API doesn't take in a type, so we can't figure out what it is.
-    CompilerType *type = NULL;
+    CompilerType *type = nullptr;
     watchpoint_sp =
         target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
     error.SetError(cw_error);
@@ -1559,7 +1559,7 @@
                      (const char *, const char *, const char *), path, triple,
                      uuid_cstr);
 
-  return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, NULL));
+  return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr));
 }
 
 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
@@ -1683,7 +1683,7 @@
     ConstString const_triple(triple.c_str());
     return const_triple.GetCString();
   }
-  return NULL;
+  return nullptr;
 }
 
 uint32_t SBTarget::GetDataByteSize() {
@@ -1969,7 +1969,7 @@
 
     if (match_count > 0) {
       ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
-      if (exe_scope == NULL)
+      if (exe_scope == nullptr)
         exe_scope = target_sp.get();
       for (uint32_t i = 0; i < match_count; ++i) {
         lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
@@ -2017,7 +2017,7 @@
 
     if (match_count > 0) {
       ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
-      if (exe_scope == NULL)
+      if (exe_scope == nullptr)
         exe_scope = target_sp.get();
       for (uint32_t i = 0; i < match_count; ++i) {
         lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
@@ -2053,7 +2053,7 @@
   LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
                      (lldb::SBAddress, uint32_t), base_addr, count);
 
-  return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, NULL));
+  return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr));
 }
 
 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
@@ -2080,7 +2080,7 @@
                                 data.GetByteSize(), error, &load_addr);
       const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
       sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
-          target_sp->GetArchitecture(), NULL, flavor_string, *addr_ptr,
+          target_sp->GetArchitecture(), nullptr, flavor_string, *addr_ptr,
           data.GetBytes(), bytes_read, count, data_from_file));
     }
   }
@@ -2095,7 +2095,7 @@
                     (lldb::SBAddress, const void *, size_t), base_addr, buf,
                     size);
 
-  return GetInstructionsWithFlavor(base_addr, NULL, buf, size);
+  return GetInstructionsWithFlavor(base_addr, nullptr, buf, size);
 }
 
 lldb::SBInstructionList
@@ -2119,7 +2119,7 @@
     const bool data_from_file = true;
 
     sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
-        target_sp->GetArchitecture(), NULL, flavor_string, addr, buf, size,
+        target_sp->GetArchitecture(), nullptr, flavor_string, addr, buf, size,
         UINT32_MAX, data_from_file));
   }
 
@@ -2132,7 +2132,7 @@
   LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
                     (lldb::addr_t, const void *, size_t), base_addr, buf, size);
 
-  return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), NULL, buf,
+  return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf,
                                    size);
 }
 
@@ -2353,9 +2353,9 @@
   SBValue expr_result;
   ValueObjectSP expr_value_sp;
   TargetSP target_sp(GetSP());
-  StackFrame *frame = NULL;
+  StackFrame *frame = nullptr;
   if (target_sp) {
-    if (expr == NULL || expr[0] == '\0') {
+    if (expr == nullptr || expr[0] == '\0') {
       return LLDB_RECORD_RESULT(expr_result);
     }
 
@@ -2409,7 +2409,7 @@
 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
 
-  lldb::SBLaunchInfo launch_info(NULL);
+  lldb::SBLaunchInfo launch_info(nullptr);
   TargetSP target_sp(GetSP());
   if (target_sp)
     launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());