diff options
| -rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 95 |
1 files changed, 50 insertions, 45 deletions
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 19c3c0e5ced..ff15fdb7d52 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -2350,57 +2350,40 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, if (name == g_lldb_class_name) { // Clang is looking for the type of "this" - - if (!frame) + + if (frame == NULL) return; - VariableList *vars = frame->GetVariableList(false); + SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction); - if (!vars) + if (!sym_ctx.function) return; - lldb::VariableSP this_var = vars->FindVariable(ConstString("this")); - - if (!this_var || - !this_var->IsInScope(frame) || - !this_var->LocationIsValidForFrame (frame)) - return; + clang::DeclContext *decl_context; - Type *this_type = this_var->GetType(); + if (sym_ctx.block && sym_ctx.block->GetInlinedFunctionInfo()) + decl_context = sym_ctx.block->GetClangDeclContextForInlinedFunction(); + else + decl_context = sym_ctx.function->GetClangDeclContext(); - if (!this_type) + if (!decl_context) return; - if (log && log->GetVerbose()) - { - log->Printf (" CEDM::FEVD[%u] Type for \"this\" is: ", current_id); - StreamString strm; - this_type->Dump(&strm, true); - log->PutCString (strm.GetData()); - } - - TypeFromUser this_user_type(this_type->GetClangFullType(), - this_type->GetClangAST()); - - m_struct_vars->m_object_pointer_type = this_user_type; + clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context); - void *pointer_target_type = NULL; - - if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(), - &pointer_target_type)) + if (!method_decl) return; - clang::QualType pointer_target_qual_type = QualType::getFromOpaquePtr(pointer_target_type); + clang::CXXRecordDecl *class_decl = method_decl->getParent(); - if (pointer_target_qual_type.isConstQualified()) - pointer_target_qual_type.removeLocalConst(); + QualType class_qual_type(class_decl->getTypeForDecl(), 0); - TypeFromUser class_user_type(pointer_target_qual_type.getAsOpaquePtr(), - this_type->GetClangAST()); + TypeFromUser class_user_type (class_qual_type.getAsOpaquePtr(), + &class_decl->getASTContext()); if (log) { - ASTDumper ast_dumper(pointer_target_qual_type); + ASTDumper ast_dumper(class_qual_type); log->Printf(" CEDM::FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString()); } @@ -2455,24 +2438,46 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, AddOneType(context, class_user_type, current_id, false); +#if 0 VariableList *vars = frame->GetVariableList(false); lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); - if (!self_var || - !self_var->IsInScope(frame) || - !self_var->LocationIsValidForFrame (frame)) - return; - - Type *self_type = self_var->GetType(); + if (self_var && + self_var->IsInScope(frame) && + self_var->LocationIsValidForFrame (frame)) { + Type *self_type = self_var->GetType(); + + if (!self_type) + return; + + TypeFromUser self_user_type(self_type->GetClangFullType(), + self_type->GetClangAST()); + } +#endif - if (!self_type) - return; + if (method_decl->isInstanceMethod()) + { + // self is a pointer to the object + + QualType class_pointer_type = method_decl->getASTContext().getObjCObjectPointerType(QualType(interface_type, 0)); - TypeFromUser self_user_type(self_type->GetClangFullType(), - self_type->GetClangAST()); + TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(), + &method_decl->getASTContext()); - m_struct_vars->m_object_pointer_type = self_user_type; + m_struct_vars->m_object_pointer_type = self_user_type; + } + else + { + // self is a Class pointer + QualType class_type = method_decl->getASTContext().getObjCClassType(); + + TypeFromUser self_user_type(class_type.getAsOpaquePtr(), + &method_decl->getASTContext()); + + m_struct_vars->m_object_pointer_type = self_user_type; + } + return; } |

