summaryrefslogtreecommitdiff
path: root/source/Symbol/SymbolContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Symbol/SymbolContext.cpp')
-rw-r--r--source/Symbol/SymbolContext.cpp56
1 files changed, 18 insertions, 38 deletions
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index da00875bfa151..a0b35cf3d0b99 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -1,9 +1,8 @@
//===-- SymbolContext.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -48,11 +47,6 @@ SymbolContext::SymbolContext(const TargetSP &t, const ModuleSP &m,
line_entry = *le;
}
-SymbolContext::SymbolContext(const SymbolContext &rhs)
- : target_sp(rhs.target_sp), module_sp(rhs.module_sp),
- comp_unit(rhs.comp_unit), function(rhs.function), block(rhs.block),
- line_entry(rhs.line_entry), symbol(rhs.symbol), variable(rhs.variable) {}
-
SymbolContext::SymbolContext(SymbolContextScope *sc_scope)
: target_sp(), module_sp(), comp_unit(nullptr), function(nullptr),
block(nullptr), line_entry(), symbol(nullptr), variable(nullptr) {
@@ -507,7 +501,7 @@ bool SymbolContext::GetParentOfInlinedScope(const Address &curr_frame_pc,
}
#ifdef LLDB_CONFIGURATION_DEBUG
else {
- ObjectFile *objfile = NULL;
+ ObjectFile *objfile = nullptr;
if (module_sp) {
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
if (symbol_vendor) {
@@ -587,10 +581,8 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
curr_block->GetContainingInlinedBlock() != nullptr)
isInlinedblock = true;
- //----------------------------------------------------------------------
// Find all types that match the current block if we have one and put them
// first in the list. Keep iterating up through all blocks.
- //----------------------------------------------------------------------
while (curr_block != nullptr && !isInlinedblock) {
type_map.ForEach(
[curr_block, &type_list](const lldb::TypeSP &type_sp) -> bool {
@@ -608,10 +600,8 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
});
curr_block = curr_block->GetParent();
}
- //----------------------------------------------------------------------
// Find all types that match the current function, if we have onem, and put
// them next in the list.
- //----------------------------------------------------------------------
if (function != nullptr && !type_map.Empty()) {
const size_t old_type_list_size = type_list.GetSize();
type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
@@ -629,10 +619,8 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
type_map.Remove(type_list.GetTypeAtIndex(i));
}
}
- //----------------------------------------------------------------------
// Find all types that match the current compile unit, if we have one, and
// put them next in the list.
- //----------------------------------------------------------------------
if (comp_unit != nullptr && !type_map.Empty()) {
const size_t old_type_list_size = type_list.GetSize();
@@ -651,10 +639,8 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
type_map.Remove(type_list.GetTypeAtIndex(i));
}
}
- //----------------------------------------------------------------------
// Find all types that match the current module, if we have one, and put them
// next in the list.
- //----------------------------------------------------------------------
if (module_sp && !type_map.Empty()) {
const size_t old_type_list_size = type_list.GetSize();
type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
@@ -671,9 +657,7 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
type_map.Remove(type_list.GetTypeAtIndex(i));
}
}
- //----------------------------------------------------------------------
// Any types that are left get copied into the list an any order.
- //----------------------------------------------------------------------
if (!type_map.Empty()) {
type_map.ForEach([&type_list](const lldb::TypeSP &type_sp) -> bool {
type_list.Insert(type_sp);
@@ -745,7 +729,7 @@ bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
uint32_t line_index = 0;
bool found = false;
- while (1) {
+ while (true) {
LineEntry this_line;
line_index = comp_unit->FindLineEntry(line_index, line_entry.line, nullptr,
false, &this_line);
@@ -794,7 +778,7 @@ bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
}
const Symbol *
-SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error) {
+SymbolContext::FindBestGlobalDataSymbol(ConstString name, Status &error) {
error.Clear();
if (!target_sp) {
@@ -950,16 +934,14 @@ SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error)
}
-//----------------------------------------------------------------------
//
// SymbolContextSpecifier
//
-//----------------------------------------------------------------------
SymbolContextSpecifier::SymbolContextSpecifier(const TargetSP &target_sp)
- : m_target_sp(target_sp), m_module_spec(), m_module_sp(), m_file_spec_ap(),
+ : m_target_sp(target_sp), m_module_spec(), m_module_sp(), m_file_spec_up(),
m_start_line(0), m_end_line(0), m_function_spec(), m_class_name(),
- m_address_range_ap(), m_type(eNothingSpecified) {}
+ m_address_range_up(), m_type(eNothingSpecified) {}
SymbolContextSpecifier::~SymbolContextSpecifier() {}
@@ -1008,7 +990,7 @@ bool SymbolContextSpecifier::AddSpecification(const char *spec_string,
// CompUnits can't necessarily be resolved here, since an inlined function
// might show up in a number of CompUnits. Instead we just convert to a
// FileSpec and store it away.
- m_file_spec_ap.reset(new FileSpec(spec_string));
+ m_file_spec_up.reset(new FileSpec(spec_string));
m_type |= eFileSpecified;
break;
case eLineStartSpecified:
@@ -1040,12 +1022,12 @@ bool SymbolContextSpecifier::AddSpecification(const char *spec_string,
void SymbolContextSpecifier::Clear() {
m_module_spec.clear();
- m_file_spec_ap.reset();
+ m_file_spec_up.reset();
m_function_spec.clear();
m_class_name.clear();
m_start_line = 0;
m_end_line = 0;
- m_address_range_ap.reset();
+ m_address_range_up.reset();
m_type = eNothingSpecified;
}
@@ -1071,7 +1053,7 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) {
}
}
if (m_type & eFileSpecified) {
- if (m_file_spec_ap.get()) {
+ if (m_file_spec_up) {
// If we don't have a block or a comp_unit, then we aren't going to match
// a source file.
if (sc.block == nullptr && sc.comp_unit == nullptr)
@@ -1085,7 +1067,7 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) {
if (inline_info != nullptr) {
was_inlined = true;
if (!FileSpec::Equal(inline_info->GetDeclaration().GetFile(),
- *(m_file_spec_ap.get()), false))
+ *(m_file_spec_up.get()), false))
return false;
}
}
@@ -1093,7 +1075,7 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) {
// Next check the comp unit, but only if the SymbolContext was not
// inlined.
if (!was_inlined && sc.comp_unit != nullptr) {
- if (!FileSpec::Equal(*(sc.comp_unit), *(m_file_spec_ap.get()), false))
+ if (!FileSpec::Equal(*(sc.comp_unit), *(m_file_spec_up.get()), false))
return false;
}
}
@@ -1166,8 +1148,8 @@ void SymbolContextSpecifier::GetDescription(
s->Printf("Module: %s\n", m_module_spec.c_str());
}
- if (m_type == eFileSpecified && m_file_spec_ap.get() != nullptr) {
- m_file_spec_ap->GetPath(path_str, PATH_MAX);
+ if (m_type == eFileSpecified && m_file_spec_up != nullptr) {
+ m_file_spec_up->GetPath(path_str, PATH_MAX);
s->Indent();
s->Printf("File: %s", path_str);
if (m_type == eLineStartSpecified) {
@@ -1204,21 +1186,19 @@ void SymbolContextSpecifier::GetDescription(
s->Printf("Class name: %s.\n", m_class_name.c_str());
}
- if (m_type == eAddressRangeSpecified && m_address_range_ap.get() != nullptr) {
+ if (m_type == eAddressRangeSpecified && m_address_range_up != nullptr) {
s->Indent();
s->PutCString("Address range: ");
- m_address_range_ap->Dump(s, m_target_sp.get(),
+ m_address_range_up->Dump(s, m_target_sp.get(),
Address::DumpStyleLoadAddress,
Address::DumpStyleFileAddress);
s->PutCString("\n");
}
}
-//----------------------------------------------------------------------
//
// SymbolContextList
//
-//----------------------------------------------------------------------
SymbolContextList::SymbolContextList() : m_symbol_contexts() {}