[Lldb-commits] [PATCH] D70827: [lldb] Remove FileSpec->CompileUnit inheritance

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 28 07:40:24 PST 2019


labath created this revision.
labath added reviewers: teemperor, JDevlieghere.
Herald added a reviewer: jdoerfert.
Herald added a project: LLDB.
labath marked 2 inline comments as done.
labath added inline comments.


================
Comment at: lldb/source/Commands/CommandObjectThread.cpp:1196
             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)
----------------
The reason the is equivalent is a bit unobvious. CompileUnit::FindLineEntry will automatically pick the primary file (the support file at index zero) if this argument is null.


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp:607
   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];
----------------
This used to be a pointer comparison, until the type of comp_unit was changed to a reference in D56564, and the whole thing still miraculously compiled.


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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70827

Files:
  lldb/include/lldb/Symbol/CompileUnit.h
  lldb/source/API/SBCompileUnit.cpp
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectSource.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Core/FileLineResolver.cpp
  lldb/source/Core/FormatEntity.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/source/Core/SourceManager.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Symbol/CompileUnit.cpp
  lldb/source/Symbol/Function.cpp
  lldb/source/Symbol/SymbolContext.cpp
  lldb/tools/lldb-test/lldb-test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70827.231434.patch
Type: text/x-patch
Size: 24835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191128/da7cb6a1/attachment-0001.bin>


More information about the lldb-commits mailing list