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. llvm-svn: 134670
This commit is contained in:
parent
d9761cd466
commit
77eaf442ce
|
@ -309,7 +309,7 @@ ASTResultSynthesizer::SynthesizeBodyResult (CompoundStmt *Body,
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -1684,8 +1684,8 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
|
|||
|
||||
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 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
|
|||
|
||||
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 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
|
|||
|
||||
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 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
|
|||
|
||||
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 @@ ClangExpressionDeclMap::GetVariableValue
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void *type_to_use;
|
||||
void *type_to_use = NULL;
|
||||
|
||||
if (parser_ast_context)
|
||||
{
|
||||
|
@ -2395,9 +2395,9 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
|
|||
|
||||
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;
|
||||
|
|
|
@ -314,7 +314,7 @@ private:
|
|||
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 @@ private:
|
|||
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, ...)
|
||||
|
||||
|
|
|
@ -641,12 +641,10 @@ IRForTarget::RewriteObjCConstString (llvm::GlobalVariable *ns_str,
|
|||
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 @@ IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr)
|
|||
}
|
||||
|
||||
clang::QualType qual_type;
|
||||
const Type *value_type;
|
||||
const Type *value_type = NULL;
|
||||
|
||||
if (name[0] == '$')
|
||||
{
|
||||
|
@ -1493,7 +1491,7 @@ IRForTarget::MaybeHandleCall (CallInst *llvm_call_inst)
|
|||
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 @@ IRForTarget::ReplaceStaticLiterals (llvm::BasicBlock &basic_block)
|
|||
|
||||
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 @@ IRForTarget::ReplaceVariables (Function &llvm_function)
|
|||
|
||||
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 @@ IRForTarget::ReplaceVariables (Function &llvm_function)
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue