Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
//===-- DWARFBaseDIE.cpp ---------------------------------------*- C++ -*-===// | //===-- DWARFBaseDIE.cpp ---------------------------------------*- C++ -*-===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "DWARFBaseDIE.h" | #include "DWARFBaseDIE.h" | ||||
#include "DWARFUnit.h" | #include "DWARFUnit.h" | ||||
#include "DWARFDebugInfoEntry.h" | #include "DWARFDebugInfoEntry.h" | ||||
#include "SymbolFileDWARF.h" | #include "SymbolFileDWARF.h" | ||||
#include "lldb/Core/Module.h" | #include "lldb/Core/Module.h" | ||||
#include "lldb/Symbol/ObjectFile.h" | #include "lldb/Symbol/ObjectFile.h" | ||||
#include "lldb/Utility/Log.h" | |||||
using namespace lldb_private; | using namespace lldb_private; | ||||
llvm::Optional<DIERef> DWARFBaseDIE::GetDIERef() const { | llvm::Optional<DIERef> DWARFBaseDIE::GetDIERef() const { | ||||
if (!IsValid()) | if (!IsValid()) | ||||
return llvm::None; | return llvm::None; | ||||
return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(), m_cu->GetDebugSection(), | return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(), m_cu->GetDebugSection(), | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const { | SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const { | ||||
if (m_cu) | if (m_cu) | ||||
return &m_cu->GetSymbolFileDWARF(); | return &m_cu->GetSymbolFileDWARF(); | ||||
else | else | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
lldb_private::TypeSystem *DWARFBaseDIE::GetTypeSystem() const { | llvm::Expected<lldb_private::TypeSystem &> DWARFBaseDIE::GetTypeSystem() const { | ||||
JDevlieghere: Seems like this could be a lot less complex with an early return:
```
if (!m_cu) {
return… | |||||
Hmm, yeah that looks better. xiaobai: Hmm, yeah that looks better. | |||||
if (m_cu) | if (!m_cu) | ||||
return llvm::make_error<llvm::StringError>( | |||||
"Unable to get TypeSystem, no compilation unit available", | |||||
llvm::inconvertibleErrorCode()); | |||||
return m_cu->GetTypeSystem(); | return m_cu->GetTypeSystem(); | ||||
else | |||||
return nullptr; | |||||
} | } | ||||
DWARFASTParser *DWARFBaseDIE::GetDWARFParser() const { | DWARFASTParser *DWARFBaseDIE::GetDWARFParser() const { | ||||
lldb_private::TypeSystem *type_system = GetTypeSystem(); | auto type_system_or_err = GetTypeSystem(); | ||||
if (type_system) | if (auto err = type_system_or_err.takeError()) { | ||||
return type_system->GetDWARFParser(); | LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS), | ||||
else | std::move(err), "Unable to get DWARFASTParser"); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
return type_system_or_err->GetDWARFParser(); | |||||
} | |||||
bool DWARFBaseDIE::HasChildren() const { | bool DWARFBaseDIE::HasChildren() const { | ||||
return m_die && m_die->HasChildren(); | return m_die && m_die->HasChildren(); | ||||
} | } | ||||
bool DWARFBaseDIE::Supports_DW_AT_APPLE_objc_complete_type() const { | bool DWARFBaseDIE::Supports_DW_AT_APPLE_objc_complete_type() const { | ||||
return IsValid() && GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu); | return IsValid() && GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu); | ||||
} | } | ||||
Show All 23 Lines |
Seems like this could be a lot less complex with an early return: