diff options
author | Greg Clayton <gclayton@apple.com> | 2015-09-08 18:15:05 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2015-09-08 18:15:05 +0000 |
commit | f73034f99a634ba9fa67960633753f729802b6c3 (patch) | |
tree | d2dd3872f57f667f3dfbfad09ff24e944627b386 /lldb/source/DataFormatters | |
parent | 21a145c341e0b2825fa7b58685bc27cac1a8cbcc (diff) | |
download | bcm5719-llvm-f73034f99a634ba9fa67960633753f729802b6c3.tar.gz bcm5719-llvm-f73034f99a634ba9fa67960633753f729802b6c3.zip |
Use LLVM casting for TypeSystem so you can cast it to subclasses.
This will keep our code cleaner and it removes the need for intrusive additions to TypeSystem like:
class TypeSystem
{
virtual ClangASTContext *
AsClangASTContext() = 0;
}
As you can now just use the llvm::dyn_cast and other casts.
llvm-svn: 247041
Diffstat (limited to 'lldb/source/DataFormatters')
-rw-r--r-- | lldb/source/DataFormatters/CoreMedia.cpp | 8 | ||||
-rw-r--r-- | lldb/source/DataFormatters/NSArray.cpp | 12 | ||||
-rw-r--r-- | lldb/source/DataFormatters/NSIndexPath.cpp | 11 | ||||
-rw-r--r-- | lldb/source/DataFormatters/VectorType.cpp | 2 |
4 files changed, 19 insertions, 14 deletions
diff --git a/lldb/source/DataFormatters/CoreMedia.cpp b/lldb/source/DataFormatters/CoreMedia.cpp index c2fe8e82128..21dd11f0ca3 100644 --- a/lldb/source/DataFormatters/CoreMedia.cpp +++ b/lldb/source/DataFormatters/CoreMedia.cpp @@ -11,7 +11,7 @@ #include "lldb/Core/Flags.h" #include "lldb/Symbol/ClangASTContext.h" - +#include "lldb/Target/Target.h" #include <inttypes.h> using namespace lldb; @@ -21,9 +21,11 @@ using namespace lldb_private::formatters; bool lldb_private::formatters::CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { - if (!valobj.GetCompilerType().IsValid()) + CompilerType type = valobj.GetCompilerType(); + if (!type.IsValid()) return false; - ClangASTContext *ast_ctx = valobj.GetCompilerType().GetTypeSystem()->AsClangASTContext(); + + ClangASTContext *ast_ctx = valobj.GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext(); if (!ast_ctx) return false; diff --git a/lldb/source/DataFormatters/NSArray.cpp b/lldb/source/DataFormatters/NSArray.cpp index 0bf340b1338..7630f6bcbcc 100644 --- a/lldb/source/DataFormatters/NSArray.cpp +++ b/lldb/source/DataFormatters/NSArray.cpp @@ -529,11 +529,15 @@ lldb_private::formatters::NSArrayISyntheticFrontEnd::NSArrayISyntheticFrontEnd ( m_items (0), m_data_ptr (0) { - if (valobj_sp && valobj_sp->GetCompilerType().IsValid()) + if (valobj_sp) { - ClangASTContext *ast = valobj_sp->GetCompilerType().GetTypeSystem()->AsClangASTContext(); - if (ast) - m_id_type = CompilerType(ast->getASTContext(), ast->getASTContext()->ObjCBuiltinIdTy); + CompilerType type = valobj_sp->GetCompilerType(); + if (type) + { + ClangASTContext *ast = valobj_sp->GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext(); + if (ast) + m_id_type = CompilerType(ast->getASTContext(), ast->getASTContext()->ObjCBuiltinIdTy); + } } } diff --git a/lldb/source/DataFormatters/NSIndexPath.cpp b/lldb/source/DataFormatters/NSIndexPath.cpp index a09cbcc3476..6f2a7c4bc1e 100644 --- a/lldb/source/DataFormatters/NSIndexPath.cpp +++ b/lldb/source/DataFormatters/NSIndexPath.cpp @@ -27,7 +27,6 @@ public: NSIndexPathSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : SyntheticChildrenFrontEnd (*valobj_sp.get()), m_ptr_size(0), - m_ast_ctx(nullptr), m_uint_star_type() { m_ptr_size = m_backend.GetTargetSP()->GetArchitecture().GetAddressByteSize(); @@ -53,11 +52,12 @@ public: TypeSystem* type_system = m_backend.GetCompilerType().GetTypeSystem(); if (!type_system) return false; - m_ast_ctx = type_system->AsClangASTContext(); - if (!m_ast_ctx) + + ClangASTContext *ast = m_backend.GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext(); + if (!ast) return false; - - m_uint_star_type = m_ast_ctx->GetPointerSizedIntType(false); + + m_uint_star_type = ast->GetPointerSizedIntType(false); static ConstString g__indexes("_indexes"); static ConstString g__length("_length"); @@ -325,7 +325,6 @@ protected: } m_impl; uint32_t m_ptr_size; - ClangASTContext* m_ast_ctx; CompilerType m_uint_star_type; }; diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index 183893ac264..b01d89050fb 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -232,7 +232,7 @@ namespace lldb_private { CompilerType parent_type(m_backend.GetCompilerType()); CompilerType element_type; parent_type.IsVectorType(&element_type, nullptr); - m_child_type = ::GetCompilerTypeForFormat(m_parent_format, element_type, parent_type.GetTypeSystem()->AsClangASTContext()); + m_child_type = ::GetCompilerTypeForFormat(m_parent_format, element_type, llvm::dyn_cast_or_null<ClangASTContext>(parent_type.GetTypeSystem())); m_num_children = ::CalculateNumChildren(parent_type, m_child_type); m_item_format = GetItemFormatForFormat(m_parent_format, |