[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/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 45c42df..c86def7 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -649,7 +649,7 @@
                                       lldb::RegisterKind reg_kind,
                                       uint32_t reg_num, Status *error_ptr,
                                       Value &value) {
-  if (reg_ctx == NULL) {
+  if (reg_ctx == nullptr) {
     if (error_ptr)
       error_ptr->SetErrorStringWithFormat("No register context in frame.\n");
   } else {
@@ -1249,7 +1249,7 @@
   if (IsLocationList()) {
     lldb::offset_t offset = 0;
     addr_t pc;
-    StackFrame *frame = NULL;
+    StackFrame *frame = nullptr;
     if (reg_ctx)
       pc = reg_ctx->GetPC();
     else {
@@ -1323,14 +1323,14 @@
   }
   std::vector<Value> stack;
 
-  Process *process = NULL;
-  StackFrame *frame = NULL;
+  Process *process = nullptr;
+  StackFrame *frame = nullptr;
 
   if (exe_ctx) {
     process = exe_ctx->GetProcessPtr();
     frame = exe_ctx->GetFramePtr();
   }
-  if (reg_ctx == NULL && frame)
+  if (reg_ctx == nullptr && frame)
     reg_ctx = frame->GetRegisterContext().get();
 
   if (initial_value_ptr)
@@ -3166,7 +3166,7 @@
     s.Indent();
     if (cu)
       s.AddressRange(start_addr + base_addr, end_addr + base_addr,
-                     cu->GetAddressByteSize(), NULL, ": ");
+                     cu->GetAddressByteSize(), nullptr, ": ");
     uint32_t loc_length = debug_loc_data.GetU16(&offset);
 
     DataExtractor locationData(debug_loc_data, offset, loc_length);
diff --git a/lldb/source/Expression/ExpressionVariable.cpp b/lldb/source/Expression/ExpressionVariable.cpp
index faac977..97305dc 100644
--- a/lldb/source/Expression/ExpressionVariable.cpp
+++ b/lldb/source/Expression/ExpressionVariable.cpp
@@ -25,7 +25,7 @@
     return const_cast<uint8_t *>(
         m_frozen_sp->GetDataExtractor().GetDataStart());
   }
-  return NULL;
+  return nullptr;
 }
 
 PersistentExpressionState::~PersistentExpressionState() {}
diff --git a/lldb/source/Expression/FunctionCaller.cpp b/lldb/source/Expression/FunctionCaller.cpp
index 5f5e3b8..618c1a1 100644
--- a/lldb/source/Expression/FunctionCaller.cpp
+++ b/lldb/source/Expression/FunctionCaller.cpp
@@ -35,10 +35,9 @@
                                const Address &functionAddress,
                                const ValueList &arg_value_list,
                                const char *name)
-    : Expression(exe_scope, eKindFunctionCaller),
-      m_execution_unit_sp(), m_parser(),
-      m_jit_module_wp(), m_name(name ? name : "<unknown>"),
-      m_function_ptr(NULL), m_function_addr(functionAddress),
+    : Expression(exe_scope, eKindFunctionCaller), m_execution_unit_sp(),
+      m_parser(), m_jit_module_wp(), m_name(name ? name : "<unknown>"),
+      m_function_ptr(nullptr), m_function_addr(functionAddress),
       m_function_return_type(return_type),
       m_wrapper_function_name("__lldb_caller_function"),
       m_wrapper_struct_name("__lldb_caller_struct"), m_wrapper_args_addrs(),
@@ -138,7 +137,7 @@
 
   Process *process = exe_ctx.GetProcessPtr();
 
-  if (process == NULL)
+  if (process == nullptr)
     return return_value;
 
   lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
@@ -239,11 +238,11 @@
 
   // FIXME: Use the errors Stream for better error reporting.
   Thread *thread = exe_ctx.GetThreadPtr();
-  if (thread == NULL) {
+  if (thread == nullptr) {
     diagnostic_manager.PutString(
         eDiagnosticSeverityError,
         "Can't call a function without a valid thread.");
-    return NULL;
+    return nullptr;
   }
 
   // Okay, now run the function:
@@ -279,7 +278,7 @@
 
   Process *process = exe_ctx.GetProcessPtr();
 
-  if (process == NULL)
+  if (process == nullptr)
     return false;
 
   lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
@@ -326,7 +325,7 @@
 
   lldb::addr_t args_addr;
 
-  if (args_addr_ptr != NULL)
+  if (args_addr_ptr != nullptr)
     args_addr = *args_addr_ptr;
   else
     args_addr = LLDB_INVALID_ADDRESS;
@@ -376,7 +375,7 @@
   if (exe_ctx.GetProcessPtr())
     exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
 
-  if (args_addr_ptr != NULL)
+  if (args_addr_ptr != nullptr)
     *args_addr_ptr = args_addr;
 
   if (return_value != lldb::eExpressionCompleted)
@@ -384,7 +383,7 @@
 
   FetchFunctionResults(exe_ctx, args_addr, results);
 
-  if (args_addr_ptr == NULL)
+  if (args_addr_ptr == nullptr)
     DeallocateFunctionResults(exe_ctx, args_addr);
 
   return lldb::eExpressionCompleted;
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index 7c0379c..34a3488 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -165,8 +165,8 @@
 
   ArchSpec arch(target->GetArchitecture());
 
-  const char *plugin_name = NULL;
-  const char *flavor_string = NULL;
+  const char *plugin_name = nullptr;
+  const char *flavor_string = nullptr;
   lldb::DisassemblerSP disassembler_sp =
       Disassembler::FindPlugin(arch, flavor_string, plugin_name);
 
@@ -251,7 +251,7 @@
     std::string s;
     llvm::raw_string_ostream oss(s);
 
-    m_module->print(oss, NULL);
+    m_module->print(oss, nullptr);
 
     oss.flush();
 
@@ -839,7 +839,7 @@
     };
 
     if (sc.module_sp) {
-      sc.module_sp->FindFunctions(spec.name, NULL, spec.mask,
+      sc.module_sp->FindFunctions(spec.name, nullptr, spec.mask,
                                   true,  // include_symbols
                                   false, // include_inlines
                                   true,  // append
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index 85eb78f..24a3cd2 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -654,7 +654,7 @@
     std::string s;
     raw_string_ostream oss(s);
 
-    module.print(oss, NULL);
+    module.print(oss, nullptr);
 
     oss.flush();
 
diff --git a/lldb/source/Expression/IRMemoryMap.cpp b/lldb/source/Expression/IRMemoryMap.cpp
index a8bf673..70e62ac 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -263,7 +263,7 @@
   if (target_sp)
     return target_sp.get();
 
-  return NULL;
+  return nullptr;
 }
 
 IRMemoryMap::Allocation::Allocation(lldb::addr_t process_alloc,
diff --git a/lldb/source/Expression/LLVMUserExpression.cpp b/lldb/source/Expression/LLVMUserExpression.cpp
index 6f5972b..5a1b750 100644
--- a/lldb/source/Expression/LLVMUserExpression.cpp
+++ b/lldb/source/Expression/LLVMUserExpression.cpp
@@ -50,7 +50,7 @@
       m_allow_objc(false), m_transformed_text(), m_execution_unit_sp(),
       m_materializer_up(), m_jit_module_wp(), m_enforce_valid_object(true),
       m_in_cplusplus_method(false), m_in_objectivec_method(false),
-      m_in_static_method(false), m_needs_object_ptr(false), m_target(NULL),
+      m_in_static_method(false), m_needs_object_ptr(false), m_target(nullptr),
       m_can_interpret(false), m_materialized_address(LLDB_INVALID_ADDRESS) {}
 
 LLVMUserExpression::~LLVMUserExpression() {
@@ -181,7 +181,7 @@
 
       if (execution_result == lldb::eExpressionInterrupted ||
           execution_result == lldb::eExpressionHitBreakpoint) {
-        const char *error_desc = NULL;
+        const char *error_desc = nullptr;
 
         if (call_plan_sp) {
           lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp
index 47aadba..a72e2a0 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -174,7 +174,7 @@
 
   Process *process = exe_ctx.GetProcessPtr();
 
-  if (process == NULL || process->GetState() != lldb::eStateStopped) {
+  if (process == nullptr || process->GetState() != lldb::eStateStopped) {
     if (execution_policy == eExecutionPolicyAlways) {
       if (log)
         log->Printf("== [UserExpression::Evaluate] Expression may not run, but "
@@ -186,7 +186,7 @@
     }
   }
 
-  if (process == NULL || !process->CanJIT())
+  if (process == nullptr || !process->CanJIT())
     execution_policy = eExecutionPolicyNever;
 
   // We need to set the expression execution thread here, turns out parse can
@@ -375,7 +375,7 @@
     return lldb::eExpressionInterrupted;
   }
 
-  if (result_valobj_sp.get() == NULL) {
+  if (result_valobj_sp.get() == nullptr) {
     result_valobj_sp = ValueObjectConstResult::Create(
         exe_ctx.GetBestExecutionContextScope(), error);
   }