diff options
Diffstat (limited to 'lldb/source/Expression/ClangExpressionDeclMap.cpp')
-rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 00c5ee9caad..c827592fcea 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -1221,12 +1221,12 @@ ClangExpressionDeclMap::GetObjectPointer return false; } - const bool ignore_const = true; + const bool object_pointer = true; VariableSP object_ptr_var = FindVariableInScope (*frame, object_name, (suppress_type_check ? NULL : &m_struct_vars->m_object_pointer_type), - ignore_const); + object_pointer); if (!object_ptr_var) { @@ -2175,7 +2175,7 @@ ClangExpressionDeclMap::FindVariableInScope StackFrame &frame, const ConstString &name, TypeFromUser *type, - bool ignore_const + bool object_pointer ) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -2198,19 +2198,41 @@ ClangExpressionDeclMap::FindVariableInScope if (var_sp && type) { - if (type->GetASTContext() == var_sp->GetType()->GetClangAST()) + TypeFromUser candidate_type(var_sp->GetType()->GetClangFullType(), + var_sp->GetType()->GetClangAST()); + + if (candidate_type.GetASTContext() != type->GetASTContext()) { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), - type->GetOpaqueQualType(), - var_sp->GetType()->GetClangFullType(), - ignore_const)) + if (log) + log->PutCString("Skipping a candidate variable because of different AST contexts"); + return lldb::VariableSP(); + } + + if (object_pointer) + { + clang::QualType desired_qual_type = clang::QualType::getFromOpaquePtr(type->GetOpaqueQualType()); + clang::QualType candidate_qual_type = clang::QualType::getFromOpaquePtr(candidate_type.GetOpaqueQualType()); + + const clang::PointerType *desired_ptr_type = desired_qual_type->getAs<clang::PointerType>(); + const clang::PointerType *candidate_ptr_type = candidate_qual_type->getAs<clang::PointerType>(); + + if (!desired_ptr_type || !candidate_ptr_type) + return lldb::VariableSP(); + + clang::QualType desired_target_type = desired_ptr_type->getPointeeType().getUnqualifiedType(); + clang::QualType candidate_target_type = candidate_ptr_type->getPointeeType().getUnqualifiedType(); + + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), + desired_target_type.getAsOpaquePtr(), + candidate_target_type.getAsOpaquePtr())) return lldb::VariableSP(); } else { - if (log) - log->PutCString("Skipping a candidate variable because of different AST contexts"); - return lldb::VariableSP(); + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), + type->GetOpaqueQualType(), + var_sp->GetType()->GetClangFullType())) + return lldb::VariableSP(); } } |