diff --git a/lldb/include/lldb/Symbol/CompilerDeclContext.h b/lldb/include/lldb/Symbol/CompilerDeclContext.h --- a/lldb/include/lldb/Symbol/CompilerDeclContext.h +++ b/lldb/include/lldb/Symbol/CompilerDeclContext.h @@ -61,27 +61,21 @@ /// Checks if this decl context represents a method of a class. /// - /// \param[out] language_ptr + /// \param[out] instance_var_name_ptr /// If non NULL and \b true is returned from this function, - /// this will indicate if the language that respresents the method. - /// - /// \param[out] is_instance_method_ptr - /// If non NULL and \b true is returned from this function, - /// this will indicate if the method is an instance function (true) - /// or a class method (false indicating the function is static, or - /// doesn't require an instance of the class to be called). - /// - /// \param[out] language_object_name_ptr - /// If non NULL and \b true is returned from this function, - /// this will indicate if implicit object name for the language + /// this will indicate the implicit variable name for the language /// like "this" for C++, and "self" for Objective C. /// + /// \param[out] instance_is_pointer_ptr + /// If non NULL and \b true is returned from this function, + /// this will indicate whether the implicit object for the language + /// is a pointer or a reference. + /// /// \return /// Returns true if this is a decl context that represents a method /// in a struct, union or class. - bool IsClassMethod(lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, - ConstString *language_object_name_ptr); + bool IsClassMethod(ConstString *instance_var_name_ptr = nullptr, + bool *instance_is_pointer_ptr = nullptr); /// Check if the given other decl context is contained in the lookup /// of this decl context (for example because the other context is a nested diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -248,23 +248,19 @@ /// If this symbol context represents a function that is a method, return /// true and provide information about the method. /// - /// \param[out] language - /// If \b true is returned, the language for the method. - /// - /// \param[out] is_instance_method - /// If \b true is returned, \b true if this is a instance method, - /// \b false if this is a static/class function. - /// - /// \param[out] language_object_name + /// \param[out] instance_var_name /// If \b true is returned, the name of the artificial variable /// for the language ("this" for C++, "self" for ObjC). /// + /// \param[out] instance_is_pointer + /// If \b true is returned, identifies whether the language's instance + /// variable is a pointer or reference. + /// /// \return /// \b True if this symbol context represents a function that /// is a method of a class, \b false otherwise. - bool GetFunctionMethodInfo(lldb::LanguageType &language, - bool &is_instance_method, - ConstString &language_object_name); + bool GetFunctionMethodInfo(ConstString *instance_var_name, + bool *instance_is_pointer); /// Sorts the types in TypeMap according to SymbolContext to TypeList /// diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -121,9 +121,9 @@ virtual ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) = 0; - virtual bool DeclContextIsClassMethod( - void *opaque_decl_ctx, lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, ConstString *language_object_name_ptr) = 0; + virtual bool DeclContextIsClassMethod(void *opaque_decl_ctx, + ConstString *instance_var_name_ptr, + bool *instance_is_pointer_ptr) = 0; virtual bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) = 0; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1147,8 +1147,7 @@ // class/instance methods, since they'll be skipped in the code that // follows anyway. CompilerDeclContext func_decl_context = function->GetDeclContext(); - if (!func_decl_context || - func_decl_context.IsClassMethod(nullptr, nullptr, nullptr)) + if (!func_decl_context || func_decl_context.IsClassMethod()) continue; // We can only prune functions for which we can copy the type. CompilerType func_clang_type = function->GetType()->GetFullCompilerType(); @@ -1279,7 +1278,7 @@ continue; // Filter out class/instance methods. - if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr)) + if (decl_ctx.IsClassMethod()) continue; AddOneFunction(context, sym_ctx.function, nullptr); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -513,9 +513,8 @@ ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override; bool DeclContextIsClassMethod(void *opaque_decl_ctx, - lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, - ConstString *language_object_name_ptr) override; + ConstString *instance_var_name_ptr, + bool *instance_is_pointer_ptr) override; bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) override; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -9501,38 +9501,36 @@ } bool TypeSystemClang::DeclContextIsClassMethod( - void *opaque_decl_ctx, lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, ConstString *language_object_name_ptr) { + void *opaque_decl_ctx, ConstString *instance_var_name_ptr, + bool *instance_is_pointer_ptr) { if (opaque_decl_ctx) { clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx; if (ObjCMethodDecl *objc_method = llvm::dyn_cast(decl_ctx)) { - if (is_instance_method_ptr) - *is_instance_method_ptr = objc_method->isInstanceMethod(); - if (language_ptr) - *language_ptr = eLanguageTypeObjC; - if (language_object_name_ptr) - language_object_name_ptr->SetCString("self"); + if (objc_method->isInstanceMethod()) { + if (instance_var_name_ptr) + instance_var_name_ptr->SetCString("self"); + if (instance_is_pointer_ptr) + *instance_is_pointer_ptr = true; + } return true; } else if (CXXMethodDecl *cxx_method = llvm::dyn_cast(decl_ctx)) { - if (is_instance_method_ptr) - *is_instance_method_ptr = cxx_method->isInstance(); - if (language_ptr) - *language_ptr = eLanguageTypeC_plus_plus; - if (language_object_name_ptr) - language_object_name_ptr->SetCString("this"); + if (cxx_method->isInstance()) { + if (instance_var_name_ptr) + instance_var_name_ptr->SetCString("this"); + if (instance_is_pointer_ptr) + *instance_is_pointer_ptr = true; + } return true; } else if (clang::FunctionDecl *function_decl = llvm::dyn_cast(decl_ctx)) { ClangASTMetadata *metadata = GetMetadata(function_decl); if (metadata && metadata->HasObjectPtr()) { - if (is_instance_method_ptr) - *is_instance_method_ptr = true; - if (language_ptr) - *language_ptr = eLanguageTypeObjC; - if (language_object_name_ptr) - language_object_name_ptr->SetCString(metadata->GetObjectPtrName()); + if (instance_var_name_ptr) + instance_var_name_ptr->SetCString(metadata->GetObjectPtrName()); + if (instance_is_pointer_ptr) + *instance_is_pointer_ptr = true; return true; } } diff --git a/lldb/source/Symbol/CompilerDeclContext.cpp b/lldb/source/Symbol/CompilerDeclContext.cpp --- a/lldb/source/Symbol/CompilerDeclContext.cpp +++ b/lldb/source/Symbol/CompilerDeclContext.cpp @@ -34,13 +34,11 @@ return ConstString(); } -bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, - ConstString *language_object_name_ptr) { +bool CompilerDeclContext::IsClassMethod(ConstString *instance_var_name_ptr, + bool *instance_is_pointer_ptr) { if (IsValid()) return m_type_system->DeclContextIsClassMethod( - m_opaque_decl_ctx, language_ptr, is_instance_method_ptr, - language_object_name_ptr); + m_opaque_decl_ctx, instance_var_name_ptr, instance_is_pointer_ptr); return false; } diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -545,17 +545,13 @@ return nullptr; } -bool SymbolContext::GetFunctionMethodInfo(lldb::LanguageType &language, - bool &is_instance_method, - ConstString &language_object_name) - -{ +bool SymbolContext::GetFunctionMethodInfo(ConstString *instance_var_name, + bool *instance_is_pointer) { Block *function_block = GetFunctionBlock(); if (function_block) { CompilerDeclContext decl_ctx = function_block->GetDeclContext(); if (decl_ctx) - return decl_ctx.IsClassMethod(&language, &is_instance_method, - &language_object_name); + return decl_ctx.IsClassMethod(instance_var_name, instance_is_pointer); } return false; } diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -553,16 +553,17 @@ // Check for direct ivars access which helps us with implicit access to // ivars with the "this->" or "self->" GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock); - lldb::LanguageType method_language = eLanguageTypeUnknown; - bool is_instance_method = false; - ConstString method_object_name; - if (m_sc.GetFunctionMethodInfo(method_language, is_instance_method, - method_object_name)) { - if (is_instance_method && method_object_name) { - var_sp = variable_list->FindVariable(method_object_name); + ConstString instance_var_name; + bool instance_is_pointer = true; + if (m_sc.GetFunctionMethodInfo(&instance_var_name, &instance_is_pointer)) { + if (instance_var_name) { + var_sp = variable_list->FindVariable(instance_var_name); if (var_sp) { separator_idx = 0; - var_expr_storage = "->"; + if (instance_is_pointer) + var_expr_storage = "->"; + else + var_expr_storage = "."; var_expr_storage += var_expr; var_expr = var_expr_storage; synthetically_added_instance_object = true;