diff options
| author | Alex Langford <apl@fb.com> | 2019-07-30 22:12:34 +0000 |
|---|---|---|
| committer | Alex Langford <apl@fb.com> | 2019-07-30 22:12:34 +0000 |
| commit | 0e252e38ef84e42cc0b6d0e6b0f0894f6867e5a7 (patch) | |
| tree | e74b7e4f611ee1a334968d8cedd4c9f3cb921269 /lldb/source/DataFormatters | |
| parent | d56dc1d926b9ee2317f3766d21700bdc77dd84f6 (diff) | |
| download | bcm5719-llvm-0e252e38ef84e42cc0b6d0e6b0f0894f6867e5a7.tar.gz bcm5719-llvm-0e252e38ef84e42cc0b6d0e6b0f0894f6867e5a7.zip | |
[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
Diffstat (limited to 'lldb/source/DataFormatters')
| -rw-r--r-- | lldb/source/DataFormatters/VectorType.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index 18880f72ef2..26fc03a4cdc 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -15,6 +15,7 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; @@ -219,13 +220,20 @@ public: CompilerType parent_type(m_backend.GetCompilerType()); CompilerType element_type; parent_type.IsVectorType(&element_type, nullptr); - TargetSP target_sp(m_backend.GetTargetSP()); - m_child_type = ::GetCompilerTypeForFormat( - m_parent_format, element_type, - target_sp - ? target_sp->GetScratchTypeSystemForLanguage(nullptr, - lldb::eLanguageTypeC) - : nullptr); + TypeSystem *type_system = nullptr; + if (auto target_sp = m_backend.GetTargetSP()) { + auto type_system_or_err = + target_sp->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC); + if (auto err = type_system_or_err.takeError()) { + LLDB_LOG_ERROR( + lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS), + std::move(err), "Unable to update from scratch TypeSystem"); + } else { + type_system = &type_system_or_err.get(); + } + } + m_child_type = + ::GetCompilerTypeForFormat(m_parent_format, element_type, type_system); m_num_children = ::CalculateNumChildren(parent_type, m_child_type); m_item_format = GetItemFormatForFormat(m_parent_format, m_child_type); return false; |

