diff options
author | Pavel Labath <pavel@labath.sk> | 2019-11-28 16:22:44 +0100 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-11-29 11:44:45 +0100 |
commit | 38870af8594726edf32aa0fd8fd9e8916df333af (patch) | |
tree | 27bb38c3c832da4ca89ffa31688c1d1056c722bb /lldb/source | |
parent | e478385e7708d0bcef43559651e6d62e387a507a (diff) | |
download | llvm-38870af8594726edf32aa0fd8fd9e8916df333af.zip llvm-38870af8594726edf32aa0fd8fd9e8916df333af.tar.gz llvm-38870af8594726edf32aa0fd8fd9e8916df333af.tar.bz2 |
[lldb] Remove FileSpec->CompileUnit inheritance
Summary:
CompileUnit is a complicated class. Having it be implicitly convertible
to a FileSpec makes reasoning about it even harder.
This patch replaces the inheritance by a simple member and an accessor
function. This avoid the need for casting in places where one needed to
force a CompileUnit to be treated as a FileSpec, and does not add much
verbosity elsewhere.
It also fixes a bug where we were wrongly comparing CompileUnit& and a
CompileUnit*, which compiled due to a combination of this inheritance
and the FileSpec*->FileSpec implicit constructor.
Reviewers: teemperor, JDevlieghere, jdoerfert
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70827
Diffstat (limited to 'lldb/source')
20 files changed, 72 insertions, 70 deletions
diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp index 581bda3..d52040d 100644 --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -50,7 +50,7 @@ SBFileSpec SBCompileUnit::GetFileSpec() const { SBFileSpec file_spec; if (m_opaque_ptr) - file_spec.SetFileSpec(*m_opaque_ptr); + file_spec.SetFileSpec(m_opaque_ptr->GetPrimaryFile()); return LLDB_RECORD_RESULT(file_spec); } @@ -106,7 +106,7 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, if (inline_file_spec && inline_file_spec->IsValid()) file_spec = inline_file_spec->ref(); else - file_spec = *m_opaque_ptr; + file_spec = m_opaque_ptr->GetPrimaryFile(); index = m_opaque_ptr->FindLineEntry( start_idx, line, inline_file_spec ? inline_file_spec->get() : nullptr, diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index a112542..3ee9ece 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -638,7 +638,8 @@ static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc, } else { // Otherwise we will compare by name... if (old_sc.comp_unit && new_sc.comp_unit) { - if (FileSpec::Equal(*old_sc.comp_unit, *new_sc.comp_unit, true)) { + if (FileSpec::Equal(old_sc.comp_unit->GetPrimaryFile(), + new_sc.comp_unit->GetPrimaryFile(), true)) { // Now check the functions: if (old_sc.function && new_sc.function && (old_sc.function->GetName() == new_sc.function->GetName())) { diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 46b8f25..e6d7d85 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -525,7 +525,7 @@ void BreakpointLocation::GetDescription(Stream *s, if (sc.comp_unit != nullptr) { s->EOL(); s->Indent("compile unit = "); - static_cast<FileSpec *>(sc.comp_unit)->GetFilename().Dump(s); + sc.comp_unit->GetPrimaryFile().GetFilename().Dump(s); if (sc.function != nullptr) { s->EOL(); diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp index 3cb0426..6b600a7 100644 --- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp @@ -102,7 +102,7 @@ Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback( return eCallbackReturnContinue; CompileUnit *cu = context.comp_unit; - FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu)); + FileSpec cu_file_spec = cu->GetPrimaryFile(); std::vector<uint32_t> line_matches; context.target_sp->GetSourceManager().FindLinesMatchingRegex( cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 469a6bb..d325b72 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -378,8 +378,10 @@ CommandCompletions::SourceFileCompleter::SearchCallback(SearchFilter &filter, } } } else { - const char *cur_file_name = context.comp_unit->GetFilename().GetCString(); - const char *cur_dir_name = context.comp_unit->GetDirectory().GetCString(); + const char *cur_file_name = + context.comp_unit->GetPrimaryFile().GetFilename().GetCString(); + const char *cur_dir_name = + context.comp_unit->GetPrimaryFile().GetDirectory().GetCString(); bool match = false; if (m_file_name && cur_file_name && @@ -391,7 +393,7 @@ CommandCompletions::SourceFileCompleter::SearchCallback(SearchFilter &filter, match = false; if (match) { - m_matching_files.AppendIfUnique(context.comp_unit); + m_matching_files.AppendIfUnique(context.comp_unit->GetPrimaryFile()); } } } diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index fd1b158..f2591b4 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -256,7 +256,8 @@ protected: if (num_matches > 0) strm << "\n\n"; strm << "Lines found for file " << file_spec_name - << " in compilation unit " << cu->GetFilename() << " in `" + << " in compilation unit " + << cu->GetPrimaryFile().GetFilename() << " in `" << module_file_name << "\n"; cu_header_printed = true; } @@ -1077,7 +1078,8 @@ protected: if (m_options.show_bp_locs) { m_breakpoint_locations.Clear(); const bool show_inlines = true; - m_breakpoint_locations.Reset(*sc.comp_unit, 0, show_inlines); + m_breakpoint_locations.Reset(sc.comp_unit->GetPrimaryFile(), 0, + show_inlines); SearchFilterForUnconstrainedSearches target_search_filter( target->shared_from_this()); target_search_filter.Search(m_breakpoint_locations); @@ -1106,8 +1108,8 @@ protected: ? sc.line_entry.column : 0; target->GetSourceManager().DisplaySourceLinesWithLineNumbers( - sc.comp_unit, sc.line_entry.line, column, lines_to_back_up, - m_options.num_lines - lines_to_back_up, "->", + sc.comp_unit->GetPrimaryFile(), sc.line_entry.line, column, + lines_to_back_up, m_options.num_lines - lines_to_back_up, "->", &result.GetOutputStream(), GetBreakpointLocations()); result.SetStatus(eReturnStatusSuccessFinishResult); } @@ -1190,18 +1192,18 @@ protected: if (num_matches > 1) { bool got_multiple = false; - FileSpec *test_cu_spec = nullptr; + CompileUnit *test_cu = nullptr; for (unsigned i = 0; i < num_matches; i++) { SymbolContext sc; sc_list.GetContextAtIndex(i, sc); if (sc.comp_unit) { - if (test_cu_spec) { - if (test_cu_spec != static_cast<FileSpec *>(sc.comp_unit)) + if (test_cu) { + if (test_cu != sc.comp_unit) got_multiple = true; break; } else - test_cu_spec = sc.comp_unit; + test_cu = sc.comp_unit; } } if (got_multiple) { @@ -1218,7 +1220,8 @@ protected: if (sc.comp_unit) { if (m_options.show_bp_locs) { const bool show_inlines = true; - m_breakpoint_locations.Reset(*sc.comp_unit, 0, show_inlines); + m_breakpoint_locations.Reset(sc.comp_unit->GetPrimaryFile(), 0, + show_inlines); SearchFilterForUnconstrainedSearches target_search_filter( target->shared_from_this()); target_search_filter.Search(m_breakpoint_locations); @@ -1229,7 +1232,7 @@ protected: m_options.num_lines = 10; const uint32_t column = 0; target->GetSourceManager().DisplaySourceLinesWithLineNumbers( - sc.comp_unit, m_options.start_line, column, 0, + sc.comp_unit->GetPrimaryFile(), m_options.start_line, column, 0, m_options.num_lines, "", &result.GetOutputStream(), GetBreakpointLocations()); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index d77207b..9f4e58e 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -816,15 +816,14 @@ protected: return; if (sc.module_sp) { if (sc.comp_unit) { - s.Printf("Global variables for %s in %s:\n", - sc.comp_unit->GetPath().c_str(), - sc.module_sp->GetFileSpec().GetPath().c_str()); + s.Format("Global variables for {0} in {1}:\n", + sc.comp_unit->GetPrimaryFile(), sc.module_sp->GetFileSpec()); } else { s.Printf("Global variables for %s\n", sc.module_sp->GetFileSpec().GetPath().c_str()); } } else if (sc.comp_unit) { - s.Printf("Global variables for %s\n", sc.comp_unit->GetPath().c_str()); + s.Format("Global variables for {0}\n", sc.comp_unit->GetPrimaryFile()); } for (VariableSP var_sp : variable_list) { @@ -926,9 +925,9 @@ protected: if (!success) { if (frame) { if (comp_unit) - result.AppendErrorWithFormat( - "no global variables in current compile unit: %s\n", - comp_unit->GetPath().c_str()); + result.AppendErrorWithFormatv( + "no global variables in current compile unit: {0}\n", + comp_unit->GetPrimaryFile()); else result.AppendErrorWithFormat( "no debug information for frame %u\n", @@ -1327,8 +1326,8 @@ static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter, if (i > 0) strm << "\n\n"; - strm << "Line table for " << *static_cast<FileSpec *>(sc.comp_unit) - << " in `" << module->GetFileSpec().GetFilename() << "\n"; + strm << "Line table for " << sc.comp_unit->GetPrimaryFile() << " in `" + << module->GetFileSpec().GetFilename() << "\n"; LineTable *line_table = sc.comp_unit->GetLineTable(); if (line_table) line_table->GetDescription( diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index a74eec0..13c17df 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -1193,7 +1193,7 @@ protected: LineEntry line_entry; const bool exact = false; start_idx_ptr = sc.comp_unit->FindLineEntry( - start_idx_ptr, line_number, sc.comp_unit, exact, &line_entry); + start_idx_ptr, line_number, nullptr, exact, &line_entry); if (start_idx_ptr == UINT32_MAX) break; diff --git a/lldb/source/Core/FileLineResolver.cpp b/lldb/source/Core/FileLineResolver.cpp index 01df295..7d91d1a 100644 --- a/lldb/source/Core/FileLineResolver.cpp +++ b/lldb/source/Core/FileLineResolver.cpp @@ -36,8 +36,8 @@ FileLineResolver::SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr) { CompileUnit *cu = context.comp_unit; - if (m_inlines || - m_file_spec.Compare(*cu, m_file_spec, (bool)m_file_spec.GetDirectory())) { + if (m_inlines || m_file_spec.Compare(cu->GetPrimaryFile(), m_file_spec, + (bool)m_file_spec.GetDirectory())) { uint32_t start_file_idx = 0; uint32_t file_idx = cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false); diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index c90828f..07ca0a6 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1376,8 +1376,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, if (sc) { CompileUnit *cu = sc->comp_unit; if (cu) { - // CompileUnit is a FileSpec - if (DumpFile(s, *cu, (FileKind)entry.number)) + if (DumpFile(s, cu->GetPrimaryFile(), (FileKind)entry.number)) return true; } } diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index a14bd3d..360c8c1 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -617,7 +617,8 @@ void Module::FindCompileUnits(const FileSpec &path, for (size_t i = 0; i < num_compile_units; ++i) { sc.comp_unit = GetCompileUnitAtIndex(i).get(); if (sc.comp_unit) { - if (FileSpec::Equal(*sc.comp_unit, path, compare_directory)) + if (FileSpec::Equal(sc.comp_unit->GetPrimaryFile(), path, + compare_directory)) sc_list.Append(sc); } } diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp index 8f80caa..c49b59e 100644 --- a/lldb/source/Core/SearchFilter.cpp +++ b/lldb/source/Core/SearchFilter.cpp @@ -726,8 +726,11 @@ bool SearchFilterByModuleListAndCU::AddressPasses(Address &address) { if (m_cu_spec_list.GetSize() != 0) return false; // Has no comp_unit so can't pass the file check. } - if (m_cu_spec_list.FindFileIndex(0, sym_ctx.comp_unit, false) == UINT32_MAX) - return false; // Fails the file check + FileSpec cu_spec; + if (sym_ctx.comp_unit) + cu_spec = sym_ctx.comp_unit->GetPrimaryFile(); + if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX) + return false; // Fails the file check return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); } @@ -736,8 +739,8 @@ bool SearchFilterByModuleListAndCU::CompUnitPasses(FileSpec &fileSpec) { } bool SearchFilterByModuleListAndCU::CompUnitPasses(CompileUnit &compUnit) { - bool in_cu_list = - m_cu_spec_list.FindFileIndex(0, compUnit, false) != UINT32_MAX; + bool in_cu_list = m_cu_spec_list.FindFileIndex(0, compUnit.GetPrimaryFile(), + false) != UINT32_MAX; if (in_cu_list) { ModuleSP module_sp(compUnit.GetModule()); if (module_sp) { @@ -787,8 +790,9 @@ void SearchFilterByModuleListAndCU::Search(Searcher &searcher) { CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(cu_idx); matchingContext.comp_unit = cu_sp.get(); if (matchingContext.comp_unit) { - if (m_cu_spec_list.FindFileIndex(0, *matchingContext.comp_unit, - false) != UINT32_MAX) { + if (m_cu_spec_list.FindFileIndex( + 0, matchingContext.comp_unit->GetPrimaryFile(), false) != + UINT32_MAX) { shouldContinue = DoCUIteration(module_sp, matchingContext, searcher); if (shouldContinue == Searcher::eCallbackReturnStop) diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index 42741e4..e3780e0 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -399,24 +399,25 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec, if (num_matches != 0) { if (num_matches > 1) { SymbolContext sc; - FileSpec *test_cu_spec = nullptr; + CompileUnit *test_cu = nullptr; for (unsigned i = 0; i < num_matches; i++) { sc_list.GetContextAtIndex(i, sc); if (sc.comp_unit) { - if (test_cu_spec) { - if (test_cu_spec != static_cast<FileSpec *>(sc.comp_unit)) + if (test_cu) { + if (test_cu != sc.comp_unit) got_multiple = true; break; } else - test_cu_spec = sc.comp_unit; + test_cu = sc.comp_unit; } } } if (!got_multiple) { SymbolContext sc; sc_list.GetContextAtIndex(0, sc); - m_file_spec = sc.comp_unit; + if (sc.comp_unit) + m_file_spec = sc.comp_unit->GetPrimaryFile(); m_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec); } } diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index 29d2e8a..b2c4d08 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -731,7 +731,7 @@ void SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu, } if (next_addr) finish_sequence(); - data.support_files = map.translate(cu, *m_files); + data.support_files = map.translate(cu.GetPrimaryFile(), *m_files); } void SymbolFileBreakpad::ParseUnwindData() { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index fcdff01..837a475 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1046,7 +1046,8 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) { comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue( comp_unit.GetModule(), line_table->Prologue, dwarf_cu->GetPathStyle(), - dwarf_cu->GetCompilationDirectory().GetCString(), FileSpec(comp_unit))); + dwarf_cu->GetCompilationDirectory().GetCString(), + comp_unit.GetPrimaryFile())); return true; } @@ -1951,7 +1952,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec, const bool full_match = (bool)file_spec.GetDirectory(); bool file_spec_matches_cu_file_spec = - FileSpec::Equal(file_spec, *dc_cu, full_match); + FileSpec::Equal(file_spec, dc_cu->GetPrimaryFile(), full_match); if (check_inlines || file_spec_matches_cu_file_spec) { SymbolContext sc(m_objfile_sp->GetModule()); sc.comp_unit = dc_cu; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index dbdbf49..d3090ed 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -604,7 +604,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo * SymbolFileDWARFDebugMap::GetCompUnitInfo(const CompileUnit &comp_unit) { const uint32_t cu_count = GetNumCompileUnits(); for (uint32_t i = 0; i < cu_count; ++i) { - if (comp_unit == m_compile_unit_infos[i].compile_unit_sp.get()) + if (&comp_unit == m_compile_unit_infos[i].compile_unit_sp.get()) return &m_compile_unit_infos[i]; } return nullptr; diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index e7bc730..dcbefdc 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -373,7 +373,7 @@ bool SymbolFilePDB::ParseSupportFiles( // LLDB uses the DWARF-like file numeration (one based), // the zeroth file is the compile unit itself - support_files.Insert(0, comp_unit); + support_files.Insert(0, comp_unit.GetPrimaryFile()); return true; } @@ -1780,7 +1780,6 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit, auto line_table = std::make_unique<LineTable>(&comp_unit); // Find contributions to `compiland` from all source and header files. - std::string path = comp_unit.GetPath(); auto files = m_session_up->getSourceFilesForCompiland(*compiland_up); if (!files) return false; diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp index 8207436..6aef807 100644 --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -21,30 +21,21 @@ CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, lldb_private::LazyBool is_optimized) - : ModuleChild(module_sp), FileSpec(pathname), UserID(cu_sym_id), - m_user_data(user_data), m_language(language), m_flags(0), - m_support_files(), m_line_table_up(), m_variables(), - m_is_optimized(is_optimized) { - if (language != eLanguageTypeUnknown) - m_flags.Set(flagsParsedLanguage); - assert(module_sp); -} + : CompileUnit(module_sp, user_data, FileSpec(pathname), cu_sym_id, language, + is_optimized) {} CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, lldb_private::LazyBool is_optimized) - : ModuleChild(module_sp), FileSpec(fspec), UserID(cu_sym_id), - m_user_data(user_data), m_language(language), m_flags(0), - m_support_files(), m_line_table_up(), m_variables(), + : ModuleChild(module_sp), UserID(cu_sym_id), m_user_data(user_data), + m_language(language), m_flags(0), m_file_spec(fspec), m_is_optimized(is_optimized) { if (language != eLanguageTypeUnknown) m_flags.Set(flagsParsedLanguage); assert(module_sp); } -CompileUnit::~CompileUnit() {} - void CompileUnit::CalculateSymbolContext(SymbolContext *sc) { sc->comp_unit = this; GetModule()->CalculateSymbolContext(sc); @@ -63,7 +54,7 @@ void CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const { const char *language = Language::GetNameForLanguageType(m_language); *s << "id = " << (const UserID &)*this << ", file = \"" - << (const FileSpec &)*this << "\", language = \"" << language << '"'; + << this->GetPrimaryFile() << "\", language = \"" << language << '"'; } void CompileUnit::ForeachFunction( @@ -117,8 +108,7 @@ void CompileUnit::Dump(Stream *s, bool show_context) const { s->Printf("%p: ", static_cast<const void *>(this)); s->Indent(); *s << "CompileUnit" << static_cast<const UserID &>(*this) << ", language = \"" - << language << "\", file = '" << static_cast<const FileSpec &>(*this) - << "'\n"; + << language << "\", file = '" << GetPrimaryFile() << "'\n"; // m_types.Dump(s); @@ -255,7 +245,7 @@ void CompileUnit::ResolveSymbolContext(const FileSpec &file_spec, std::vector<uint32_t> file_indexes; const bool full_match = (bool)file_spec.GetDirectory(); bool file_spec_matches_cu_file_spec = - FileSpec::Equal(file_spec, *this, full_match); + FileSpec::Equal(file_spec, this->GetPrimaryFile(), full_match); // If we are not looking for inlined functions and our file spec doesn't // match then we are done... diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 9e81b61..c392317 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -340,7 +340,8 @@ Block &Function::GetBlock(bool can_create) { "error: unable to find module " "shared pointer for function '%s' " "in %s\n", - GetName().GetCString(), m_comp_unit->GetPath().c_str()); + GetName().GetCString(), + m_comp_unit->GetPrimaryFile().GetPath().c_str()); } m_block.SetBlockInfoHasBeenParsed(true, true); } diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index c5d8547..11548c0 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -316,7 +316,7 @@ void SymbolContext::Dump(Stream *s, Target *target) const { *s << "CompileUnit = " << comp_unit; if (comp_unit != nullptr) s->Format(" {{{0:x-16}} {1}", comp_unit->GetID(), - *static_cast<FileSpec *>(comp_unit)); + comp_unit->GetPrimaryFile()); s->EOL(); s->Indent(); *s << "Function = " << function; @@ -1055,7 +1055,8 @@ 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_up.get()), false)) + if (!FileSpec::Equal(sc.comp_unit->GetPrimaryFile(), *m_file_spec_up, + false)) return false; } } |