[Symbol] Use llvm::Expected when getting TypeSystems

Summary:
This commit achieves the following:
- Functions used to return a `TypeSystem *` return an
  `llvm::Expected<TypeSystem *>` now. This means that the result of a call
  is always checked, forcing clients to move more carefully.
- `TypeSystemMap::GetTypeSystemForLanguage` will either return an Error or a
  non-null pointer to a TypeSystem.

Reviewers: JDevlieghere, davide, compnerd

Subscribers: jdoerfert, lldb-commits

Differential Revision: https://reviews.llvm.org/D65122

llvm-svn: 367360
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 87b5b59..5cfd978 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Target/Target.h"
 
 #include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -39,16 +40,17 @@
       return;
     }
 
-    Status err;
-    TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(
-        &err, lldb::eLanguageTypeC_plus_plus);
-
-    if (!err.Success() || !type_system) {
+    auto type_system_or_err = target_sp->GetScratchTypeSystemForLanguage(
+        lldb::eLanguageTypeC_plus_plus);
+    if (auto err = type_system_or_err.takeError()) {
+      LLDB_LOG_ERROR(
+          lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS),
+          std::move(err), "Failed to get scratch ClangASTContext");
       return;
     }
 
     ClangASTContext *clang_ast_context =
-        llvm::dyn_cast<ClangASTContext>(type_system);
+        llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get());
 
     if (!clang_ast_context) {
       return;