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/Commands/CommandObjectTarget.cpp | |
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/Commands/CommandObjectTarget.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
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( |