Audited the expression parser to find uninitialized
pointers.  Some of the spots are obviously initialized
later, but it's better just to NULL the pointers out
at initialization to make the code more robust when
exposed to later changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@134670 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ASTResultSynthesizer.cpp b/source/Expression/ASTResultSynthesizer.cpp
index bae9276..0286f7a 100644
--- a/source/Expression/ASTResultSynthesizer.cpp
+++ b/source/Expression/ASTResultSynthesizer.cpp
@@ -309,7 +309,7 @@
         log->Printf("Last statement is an %s with type: %s", (is_lvalue ? "lvalue" : "rvalue"), s.c_str());
     }
     
-    clang::VarDecl *result_decl;
+    clang::VarDecl *result_decl = NULL;
     
     if (is_lvalue)
     {
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index cfe2d00..50f1e88 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -1684,8 +1684,8 @@
         
         if (const NamespaceDecl *namespace_decl = dyn_cast<NamespaceDecl>(context_decl))
         {
-            Decl *original_decl;
-            ASTContext *original_ctx;
+            Decl *original_decl = NULL;
+            ASTContext *original_ctx = NULL;
             
             if (log)
                 log->Printf("Resolving the containing context's origin...");
@@ -1717,7 +1717,7 @@
                 
             DeclContextLookupConstResult original_lookup_result = original_ctx->getExternalSource()->FindExternalVisibleDeclsByName(original_decl_context, context.m_decl_name);
                         
-            NamedDecl *const *iter;
+            NamedDecl *const *iter = NULL;
             
             for (iter = original_lookup_result.first;
                  iter != original_lookup_result.second;
@@ -1866,7 +1866,7 @@
             
             m_struct_vars->m_object_pointer_type = this_user_type;
             
-            void *pointer_target_type;
+            void *pointer_target_type = NULL;
             
             if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(),
                                                 &pointer_target_type))
@@ -1915,7 +1915,7 @@
             
             m_struct_vars->m_object_pointer_type = self_user_type;
 
-            void *pointer_target_type;
+            void *pointer_target_type = NULL;
         
             if (!ClangASTContext::IsPointerType(self_user_type.GetOpaqueQualType(),
                                                 &pointer_target_type))
@@ -2075,7 +2075,7 @@
         return NULL;
     }
         
-    void *type_to_use;
+    void *type_to_use = NULL;
     
     if (parser_ast_context)
     {
@@ -2395,9 +2395,9 @@
     
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
-    NamedDecl *fun_decl;
+    NamedDecl *fun_decl = NULL;
     std::auto_ptr<Value> fun_location(new Value);
-    const Address *fun_address;
+    const Address *fun_address = NULL;
     
     // only valid for Functions, not for Symbols
     void *fun_opaque_type = NULL;
diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp
index 584de69..09f520c 100644
--- a/source/Expression/IRDynamicChecks.cpp
+++ b/source/Expression/IRDynamicChecks.cpp
@@ -314,7 +314,7 @@
         if (!m_valid_pointer_check_func)
             m_valid_pointer_check_func = BuildPointerValidatorFunc(m_checker_functions.m_valid_pointer_check->StartAddress());
         
-        llvm::Value *dereferenced_ptr;
+        llvm::Value *dereferenced_ptr = NULL;
         
         if (llvm::LoadInst *li = dyn_cast<llvm::LoadInst> (inst))
             dereferenced_ptr = li->getPointerOperand();
@@ -382,7 +382,7 @@
         if (!m_objc_object_check_func)
             m_objc_object_check_func = BuildPointerValidatorFunc(m_checker_functions.m_objc_object_check->StartAddress());
         
-        llvm::Value *target_object;
+        llvm::Value *target_object = NULL;
         
         // id objc_msgSend(id theReceiver, SEL theSelector, ...)
         
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index 26255ac..03716ff 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -641,12 +641,10 @@
         m_CFStringCreateWithBytes = ConstantExpr::getIntToPtr(CFSCWB_addr_int, CFSCWB_ptr_ty);
     }
     
-    ConstantArray *string_array;
+    ConstantArray *string_array = NULL;
     
     if (cstr)
         string_array = dyn_cast<ConstantArray>(cstr->getInitializer());
-    else
-        string_array = NULL;
                         
     SmallVector <Value*, 5> CFSCWB_arguments;
     
@@ -1266,7 +1264,7 @@
         }
         
         clang::QualType qual_type;
-        const Type *value_type;
+        const Type *value_type = NULL;
         
         if (name[0] == '$')
         {
@@ -1493,7 +1491,7 @@
     if (log)
         log->Printf("Found \"%s\" at 0x%llx", str.GetCString(), fun_addr);
     
-    Value *fun_addr_ptr;
+    Value *fun_addr_ptr = NULL;
             
     if (!fun_value_ptr || !*fun_value_ptr)
     {
@@ -1806,12 +1804,12 @@
 
 static bool isGuardVariableRef(Value *V)
 {
-    Constant *Old;
+    Constant *Old = NULL;
     
     if (!(Old = dyn_cast<Constant>(V)))
         return false;
     
-    ConstantExpr *CE;
+    ConstantExpr *CE = NULL;
     
     if ((CE = dyn_cast<ConstantExpr>(V)))
     {
@@ -2121,8 +2119,8 @@
         
     for (element_index = 0; element_index < num_elements; ++element_index)
     {
-        const clang::NamedDecl *decl;
-        Value *value;
+        const clang::NamedDecl *decl = NULL;
+        Value *value = NULL;
         off_t offset;
         lldb_private::ConstString name;
         
@@ -2144,7 +2142,7 @@
         ConstantInt *offset_int(ConstantInt::getSigned(offset_type, offset));
         GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create(argument, offset_int, "", FirstEntryInstruction);
                 
-        Value *replacement;
+        Value *replacement = NULL;
         
         // Per the comment at ASTResultSynthesizer::SynthesizeBodyResult, in cases where the result
         // variable is an rvalue, we have to synthesize a dereference of the appropriate structure