diff options
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/Expression/ClangExpressionDeclMap.h | 6 | ||||
-rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 44 | ||||
-rw-r--r-- | lldb/test/lang/cpp/this/TestCPPThis.py | 2 |
3 files changed, 39 insertions, 13 deletions
diff --git a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h index 7dccb0627a4..a300053de33 100644 --- a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h +++ b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h @@ -809,6 +809,10 @@ private: /// during parsing, in which case we don't know its type; hence the /// default. /// + /// @param[in] object_pointer + /// The type expected is an object type. This means we will ignore + /// constness of the pointer target. + /// /// @return /// The LLDB Variable found, or NULL if none was found. //------------------------------------------------------------------ @@ -816,7 +820,7 @@ private: FindVariableInScope (StackFrame &frame, const ConstString &name, TypeFromUser *type = NULL, - bool ignore_const = false); + bool object_pointer = false); //------------------------------------------------------------------ /// Given a target, find a data symbol that has the given name. 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(); } } diff --git a/lldb/test/lang/cpp/this/TestCPPThis.py b/lldb/test/lang/cpp/this/TestCPPThis.py index fa535c77fb8..1d1a7e8fb61 100644 --- a/lldb/test/lang/cpp/this/TestCPPThis.py +++ b/lldb/test/lang/cpp/this/TestCPPThis.py @@ -53,7 +53,7 @@ class CPPThisTestCase(TestBase): self.expect("expression -- m_a = 2", startstr = "(int) $1 = 2") - self.expect("expression -- m_a", + self.expect("expression -- (int)getpid(); m_a", startstr = "(int) $2 = 2") self.runCmd("process continue") |