[Lldb-commits] [lldb] r134670 - in /lldb/trunk/source/Expression: ASTResultSynthesizer.cpp ClangExpressionDeclMap.cpp IRDynamicChecks.cpp IRForTarget.cpp

Sean Callanan scallanan at apple.com
Thu Jul 7 17:39:14 PDT 2011


Author: spyffe
Date: Thu Jul  7 19:39:14 2011
New Revision: 134670

URL: http://llvm.org/viewvc/llvm-project?rev=134670&view=rev
Log:
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.

Modified:
    lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/IRDynamicChecks.cpp
    lldb/trunk/source/Expression/IRForTarget.cpp

Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=134670&r1=134669&r2=134670&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Thu Jul  7 19:39:14 2011
@@ -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)
     {

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=134670&r1=134669&r2=134670&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Jul  7 19:39:14 2011
@@ -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;

Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=134670&r1=134669&r2=134670&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original)
+++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Thu Jul  7 19:39:14 2011
@@ -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, ...)
         

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=134670&r1=134669&r2=134670&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Jul  7 19:39:14 2011
@@ -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





More information about the lldb-commits mailing list