Michael137 added inline comments.
================
Comment at: lldb/source/Core/ModuleList.cpp:1080
+ bool ret = true;
+ ForEach([&](const ModuleSP &module_sp) {
+ ret &= callback(module_sp);
----------------
aprantl wrote:
> kastiglione wrote:
> > I wonder why ForEach doesn't deal out a `Module &`? I would think a
> > ModuleList should not allow for null Module pointers.
> I think this is historic. +1 for taking a Module & (unless we for some reason
> need a shared_ptr in the lambda).
I was wondering that myself. 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).
A compromise could be to document that these pointers are guaranteed to be
non-null and add an assert into `ForEach`. AFAICT all call-sites assume the
pointer is non-null anyway
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138724/new/
https://reviews.llvm.org/D138724
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits