This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Default can_create to true in GetChildMemberWithName (NFC)
ClosedPublic

Authored by kastiglione on Jun 1 2023, 9:14 PM.

Details

Summary

It turns out all existing callers of GetChildMemberWithName pass true for can_create.
This change makes true the default value, callers don't have to pass an opaque true.

Diff Detail

Event Timeline

kastiglione created this revision.Jun 1 2023, 9:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 9:14 PM
kastiglione requested review of this revision.Jun 1 2023, 9:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 9:14 PM

If every caller sets this to true, why not remove the argument altogether? It looks like ValueObjectRegister::GetChildMemberWithName doesn't use the argument, ValueObject::GetChildMemberWithName and ValueObjectSynthetic::GetChildMemberWithName just pass it along to GetChildAtIndex.

That's an option too, which I considered. I went with this as a more
conservative change. If there's agreement to remove it then I can change it.

correction: there's still an overload of GetChildAtNamePath, which takes a can_create value and passes it through to GetChildMemberWithName. However that function isn't used, and could be deleted. To delete the parameter, that overload of GetChildMemberWithName would need to be deleted too. In general, I'm still in favor of the conservative choice of giving it a default. Deleting it altogether is an easy follow up, if so desired.

To expand the conversation, I have also opened D152031 which makes the same change to GetChildAtIndex.

jingham accepted this revision.Jun 13 2023, 10:40 AM

It's OK to retain this as the default, and as you say, taking it out would be a trivial patch after this work. The control does allow you to do "Have I already made this child" before setting about to make it, though I can't currently see anywhere where we could use this information.

This revision is now accepted and ready to land.Jun 13 2023, 10:40 AM
bulbazord accepted this revision.Jun 13 2023, 11:09 AM

I'm alright with this if Jim is. I think we should remove this parameter since it's never set to anything other than true from what I understand, but that can be done in a follow-up.