summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/SourceManager.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-11-28 16:22:44 +0100
committerPavel Labath <pavel@labath.sk>2019-11-29 11:44:45 +0100
commit38870af8594726edf32aa0fd8fd9e8916df333af (patch)
tree27bb38c3c832da4ca89ffa31688c1d1056c722bb /lldb/source/Core/SourceManager.cpp
parente478385e7708d0bcef43559651e6d62e387a507a (diff)
downloadbcm5719-llvm-38870af8594726edf32aa0fd8fd9e8916df333af.tar.gz
bcm5719-llvm-38870af8594726edf32aa0fd8fd9e8916df333af.zip
[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/Core/SourceManager.cpp')
-rw-r--r--lldb/source/Core/SourceManager.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index 42741e4ba4f..e3780e0b071 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);
}
}
OpenPOWER on IntegriCloud