[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/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 9c92805..f083b92 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -60,7 +60,7 @@
 
 static llvm::Value *FindEntryInstruction(llvm::Function *function) {
   if (function->empty())
-    return NULL;
+    return nullptr;
 
   return function->getEntryBlock().getFirstNonPHIOrDbg();
 }
@@ -71,11 +71,12 @@
                          lldb_private::Stream &error_stream,
                          const char *func_name)
     : ModulePass(ID), m_resolve_vars(resolve_vars), m_func_name(func_name),
-      m_module(NULL), m_decl_map(decl_map), m_CFStringCreateWithBytes(NULL),
-      m_sel_registerName(NULL), m_objc_getClass(NULL), m_intptr_ty(NULL),
-      m_error_stream(error_stream),
-      m_execution_unit(execution_unit), m_result_store(NULL),
-      m_result_is_pointer(false), m_reloc_placeholder(NULL),
+      m_module(nullptr), m_decl_map(decl_map),
+      m_CFStringCreateWithBytes(nullptr), m_sel_registerName(nullptr),
+      m_objc_getClass(nullptr), m_intptr_ty(nullptr),
+      m_error_stream(error_stream), m_execution_unit(execution_unit),
+      m_result_store(nullptr), m_result_is_pointer(false),
+      m_reloc_placeholder(nullptr),
       m_entry_instruction_finder(FindEntryInstruction) {}
 
 /* Handy utility functions used at several places in the code */
@@ -116,7 +117,7 @@
       module->getNamedMetadata("clang.global.decl.ptrs");
 
   if (!named_metadata)
-    return NULL;
+    return nullptr;
 
   unsigned num_nodes = named_metadata->getNumOperands();
   unsigned node_index;
@@ -125,7 +126,7 @@
     llvm::MDNode *metadata_node =
         dyn_cast<llvm::MDNode>(named_metadata->getOperand(node_index));
     if (!metadata_node)
-      return NULL;
+      return nullptr;
 
     if (metadata_node->getNumOperands() != 2)
       continue;
@@ -138,14 +139,14 @@
         mdconst::dyn_extract<ConstantInt>(metadata_node->getOperand(1));
 
     if (!constant_int)
-      return NULL;
+      return nullptr;
 
     uintptr_t ptr = constant_int->getZExtValue();
 
     return reinterpret_cast<clang::NamedDecl *>(ptr);
   }
 
-  return NULL;
+  return nullptr;
 }
 
 clang::NamedDecl *IRForTarget::DeclForGlobal(GlobalValue *global_val) {
@@ -164,7 +165,7 @@
   ValueSymbolTable &value_symbol_table = m_module->getValueSymbolTable();
 
   std::string result_name_str;
-  const char *result_name = NULL;
+  const char *result_name = nullptr;
 
   for (ValueSymbolTable::iterator vi = value_symbol_table.begin(),
                                   ve = value_symbol_table.end();
@@ -342,8 +343,8 @@
 
   GlobalVariable *new_result_global = new GlobalVariable(
       (*m_module), result_global->getType()->getElementType(),
-      false,                              /* not constant */
-      GlobalValue::ExternalLinkage, NULL, /* no initializer */
+      false,                                 /* not constant */
+      GlobalValue::ExternalLinkage, nullptr, /* no initializer */
       m_result_name.GetCString());
 
   // It's too late in compilation to create a new VarDecl for this, but we
@@ -488,7 +489,7 @@
         CFSCWB_ty, ConstantExpr::getIntToPtr(CFSCWB_addr_int, CFSCWB_ptr_ty)};
   }
 
-  ConstantDataSequential *string_array = NULL;
+  ConstantDataSequential *string_array = nullptr;
 
   if (cstr)
     string_array = dyn_cast<ConstantDataSequential>(cstr->getInitializer());
@@ -733,7 +734,7 @@
       }
 
       if (!cstr_array)
-        cstr_global = NULL;
+        cstr_global = nullptr;
 
       if (!RewriteObjCConstString(nsstring_global, cstr_global)) {
         if (log)
@@ -1149,8 +1150,8 @@
     return false;
 
   GlobalVariable *persistent_global = new GlobalVariable(
-      (*m_module), alloc->getType(), false, /* not constant */
-      GlobalValue::ExternalLinkage, NULL,   /* no initializer */
+      (*m_module), alloc->getType(), false,  /* not constant */
+      GlobalValue::ExternalLinkage, nullptr, /* no initializer */
       alloc->getName().str());
 
   // What we're going to do here is make believe this was a regular old
@@ -1346,13 +1347,13 @@
     std::string name(named_decl->getName().str());
 
     clang::ValueDecl *value_decl = dyn_cast<clang::ValueDecl>(named_decl);
-    if (value_decl == NULL)
+    if (value_decl == nullptr)
       return false;
 
     lldb_private::CompilerType compiler_type(&value_decl->getASTContext(),
                                              value_decl->getType());
 
-    const Type *value_type = NULL;
+    const Type *value_type = nullptr;
 
     if (name[0] == '$') {
       // The $__lldb_expr_result name indicates the return value has allocated
@@ -1630,12 +1631,12 @@
 }
 
 static bool isGuardVariableRef(Value *V) {
-  Constant *Old = NULL;
+  Constant *Old = nullptr;
 
   if (!(Old = dyn_cast<Constant>(V)))
     return false;
 
-  ConstantExpr *CE = NULL;
+  ConstantExpr *CE = nullptr;
 
   if ((CE = dyn_cast<ConstantExpr>(V))) {
     if (CE->getOpcode() != Instruction::BitCast)
@@ -1930,8 +1931,8 @@
   }
 
   for (element_index = 0; element_index < num_elements; ++element_index) {
-    const clang::NamedDecl *decl = NULL;
-    Value *value = NULL;
+    const clang::NamedDecl *decl = nullptr;
+    Value *value = nullptr;
     lldb::offset_t offset;
     lldb_private::ConstString name;
 
@@ -2051,7 +2052,7 @@
     std::string s;
     raw_string_ostream oss(s);
 
-    m_module->print(oss, NULL);
+    m_module->print(oss, nullptr);
 
     oss.flush();
 
@@ -2088,7 +2089,7 @@
   m_reloc_placeholder = new llvm::GlobalVariable(
       (*m_module), int8_ty, false /* IsConstant */,
       GlobalVariable::InternalLinkage, Constant::getNullValue(int8_ty),
-      "reloc_placeholder", NULL /* InsertBefore */,
+      "reloc_placeholder", nullptr /* InsertBefore */,
       GlobalVariable::NotThreadLocal /* ThreadLocal */, 0 /* AddressSpace */);
 
   ////////////////////////////////////////////////////////////
@@ -2110,7 +2111,7 @@
     std::string s;
     raw_string_ostream oss(s);
 
-    m_module->print(oss, NULL);
+    m_module->print(oss, nullptr);
 
     oss.flush();
 
@@ -2245,7 +2246,7 @@
     std::string s;
     raw_string_ostream oss(s);
 
-    m_module->print(oss, NULL);
+    m_module->print(oss, nullptr);
 
     oss.flush();