This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho][nfc] Remove unnecessary use of Optional<T*>
ClosedPublic

Authored by oontvoo on Jun 1 2021, 1:11 PM.

Details

Summary

In all of these cases, the functions could simply return a nullptr instead of {}.
There is no case where Optional<nullptr> has a special meaning.

Diff Detail

Event Timeline

oontvoo created this revision.Jun 1 2021, 1:11 PM
Herald added a reviewer: gkm. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
oontvoo requested review of this revision.Jun 1 2021, 1:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2021, 1:11 PM
thakis accepted this revision.Jun 1 2021, 1:14 PM
thakis added a subscriber: thakis.

I guess the idea was that the Optional forces you to "null" check, while the pointer doesn't? Fine to land if you want, but fine to not land too imho.

This revision is now accepted and ready to land.Jun 1 2021, 1:14 PM
int3 accepted this revision.EditedJun 1 2021, 1:54 PM

I like the safety that Optional<T*> gives, but I'm also aware that we aren't consistent about using it in our codebase (and I like consistency), so I'm fine with this

I guess the idea was that the Optional forces you to "null" check, while the pointer doesn't? Fine to land if you want, but fine to not land too imho.

I like the safety that Optional<T*> gives, but I'm also aware that we aren't consistent about using it in our codebase (and I like consistency), so I'm fine with this

Thanks! IMO, null is already a sentinel value, so why not use it? :-)

This revision was landed with ongoing or failed builds.Jun 1 2021, 3:35 PM
This revision was automatically updated to reflect the committed changes.