Currently all callsites already assume the pointer is non-null.
This patch just asserts this assumption.
This is practically enforced by ModuleList::Append
which won't add nullptrs to m_modules.
Differential D139082
[lldb][Module] Document ModuleList::ForEach and assert nullness Michael137 on Dec 1 2022, 1:31 AM. Authored by
Details Currently all callsites already assume the pointer is non-null. This is practically enforced by ModuleList::Append
Diff Detail
Event TimelineComment Actions If we assert non-null, why still pass a shared pointer? Could we have the lambda take a Module &? Comment Actions I took a stab at changing it to pass a reference but turns out there's several places where we end up storing the shared_ptr. If we changed this to a reference we'd have to call shared_from_this for those cases. Which is a bit iffy considering calling it on references that are not shared_ptr owned would throw (which can't happen currently but seems similarly awkward to the current API). |