[Lldb-commits] [lldb] r251151 - Fixed some issues with reporting "this" when the current function is not listed
Sean Callanan via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 23 14:45:03 PDT 2015
Author: spyffe
Date: Fri Oct 23 16:45:02 2015
New Revision: 251151
URL: http://llvm.org/viewvc/llvm-project?rev=251151&view=rev
Log:
Fixed some issues with reporting "this" when the current function is not listed
in DWARF as a member of a class, but it has a "this" parameter. Specifically,
*this needs to have the LLDB expression added as a method.
This fixes TestWithLimitDebugInfo.
Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp?rev=251151&r1=251150&r2=251151&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Fri Oct 23 16:45:02 2015
@@ -1086,28 +1086,7 @@ ClangExpressionDeclMap::FindExternalVisi
log->Printf(" CEDM::FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
}
- TypeFromParser class_type = CopyClassType(class_user_type, current_id);
-
- if (!class_type.IsValid())
- return;
-
- TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(QualType::getFromOpaquePtr(class_type.GetOpaqueQualType()));
-
- if (!type_source_info)
- return;
-
- TypedefDecl *typedef_decl = TypedefDecl::Create(*m_ast_context,
- m_ast_context->getTranslationUnitDecl(),
- SourceLocation(),
- SourceLocation(),
- context.m_decl_name.getAsIdentifierInfo(),
- type_source_info);
-
-
- if (!typedef_decl)
- return;
-
- context.AddNamedDecl(typedef_decl);
+ AddThisType(context, class_user_type, current_id);
if (method_decl->isInstance())
{
@@ -1143,20 +1122,17 @@ ClangExpressionDeclMap::FindExternalVisi
if (!this_type)
return;
- CompilerType pointee_type = this_type->GetForwardCompilerType ().GetPointeeType();
+ TypeFromUser pointee_type = this_type->GetForwardCompilerType ().GetPointeeType();
if (pointee_type.IsValid())
{
if (log)
{
- ASTDumper ast_dumper(this_type->GetFullCompilerType ());
- log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
+ ASTDumper ast_dumper(pointee_type);
+ log->Printf(" FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
}
-
- TypeFromUser class_user_type(pointee_type);
- AddOneType(context, class_user_type, current_id);
-
-
+
+ AddThisType(context, pointee_type, current_id);
TypeFromUser this_user_type(this_type->GetFullCompilerType ());
m_struct_vars->m_object_pointer_type = this_user_type;
return;
@@ -2156,9 +2132,10 @@ ClangExpressionDeclMap::AddOneFunction (
}
}
-TypeFromParser
-ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut,
- unsigned int current_id)
+void
+ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
+ TypeFromUser &ut,
+ unsigned int current_id)
{
CompilerType copied_clang_type = GuardedCopyType(ut);
@@ -2167,9 +2144,9 @@ ClangExpressionDeclMap::CopyClassType(Ty
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
- log->Printf("ClangExpressionDeclMap::CopyClassType - Couldn't import the type");
+ log->Printf("ClangExpressionDeclMap::AddThisType - Couldn't import the type");
- return TypeFromParser();
+ return;
}
if (copied_clang_type.IsAggregateType() && copied_clang_type.GetCompleteType ())
@@ -2204,7 +2181,31 @@ ClangExpressionDeclMap::CopyClassType(Ty
is_artificial);
}
- return TypeFromParser(copied_clang_type);
+ if (!copied_clang_type.IsValid())
+ return;
+
+ TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(QualType::getFromOpaquePtr(copied_clang_type.GetOpaqueQualType()));
+
+ if (!type_source_info)
+ return;
+
+ // Construct a typedef type because if "*this" is a templated type we can't just return ClassTemplateSpecializationDecls in response to name queries.
+ // Using a typedef makes this much more robust.
+
+ TypedefDecl *typedef_decl = TypedefDecl::Create(*m_ast_context,
+ m_ast_context->getTranslationUnitDecl(),
+ SourceLocation(),
+ SourceLocation(),
+ context.m_decl_name.getAsIdentifierInfo(),
+ type_source_info);
+
+
+ if (!typedef_decl)
+ return;
+
+ context.AddNamedDecl(typedef_decl);
+
+ return;
}
void
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h?rev=251151&r1=251150&r2=251151&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Fri Oct 23 16:45:02 2015
@@ -694,16 +694,19 @@ private:
unsigned int current_id);
//------------------------------------------------------------------
- /// Copy a C++ class type into the parser's AST context and add a
- /// member function declaration to it for the expression.
+ /// Generate a Decl for "*this" and add a member function declaration
+ /// to it for the expression, then report it.
+ ///
+ /// @param[in] context
+ /// The NameSearchContext to use when constructing the Decl.
///
/// @param[in] type
- /// The type that needs to be created.
+ /// The type for *this.
//------------------------------------------------------------------
-
- TypeFromParser
- CopyClassType(TypeFromUser &type,
- unsigned int current_id);
+ void
+ AddThisType(NameSearchContext &context,
+ TypeFromUser &type,
+ unsigned int current_id);
};
} // namespace lldb_private
More information about the lldb-commits
mailing list