This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Make shared_from_this-related code safer
ClosedPublic

Authored by tatyana-krasnukha on Feb 13 2020, 7:05 AM.

Details

Summary

The idea is: the fewer classes make an assumption that a target object is already managed by a shared_ptr - the fewer ways to make a mistake.

Pass TargetSP to filters' CreateFromStructuredData, don't let them guess whether the target object is managed by a shared_ptr.

Make Breakpoint sure that m_target.shared_from_this() is safe by passing TargetSP to all its static Create*** member-functions.
This should be enough since Breakpoint's constructors are private/protected and never called directly (except by Target itself).

The patch is a consequence of D74556.

Diff Detail

Event Timeline

jingham accepted this revision.Feb 13 2020, 10:28 AM
jingham added a subscriber: jingham.

LGTM

Targets and Breakpoints should only ever be managed by SP in lldb, so enforcing that seems like a good cleanup.

This revision is now accepted and ready to land.Feb 13 2020, 10:28 AM