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
diff --git a/lldb/source/DataFormatters/NSIndexPath.cpp b/lldb/source/DataFormatters/NSIndexPath.cpp
index a09cbcc..6f2a7c4 100644
--- a/lldb/source/DataFormatters/NSIndexPath.cpp
+++ b/lldb/source/DataFormatters/NSIndexPath.cpp
@@ -27,7 +27,6 @@
     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 @@
         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 @@
     } m_impl;
     
     uint32_t m_ptr_size;
-    ClangASTContext* m_ast_ctx;
     CompilerType m_uint_star_type;
 };