This is an archive of the discontinued LLVM Phabricator instance.

[flang] Restore Optional::value() (NFC)
ClosedPublic

Authored by kazu on Jun 25 2022, 12:18 PM.

Details

Summary

This patch restores several calls to Optional::value() in preference
to Optional::operator*.

The Flang C++ Style Guide tells us to use x.value() where no presence
test is obviously protecting a *x reference to the contents.

Diff Detail

Event Timeline

kazu created this revision.Jun 25 2022, 12:18 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 25 2022, 12:18 PM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
kazu requested review of this revision.Jun 25 2022, 12:18 PM
clementval added a comment.EditedJun 25 2022, 12:32 PM

I'm a bit lost with your changes here. Earlier you removed the use of the value() or equivalent function and now you are introducing it back? Can we have a clear plan of action on this? Or is it just to stick with our guidelines? Is so there are more to change.

kazu added a comment.Jun 25 2022, 1:12 PM

I'm a bit lost with your changes here. Earlier you removed the use of the value() or equivalent function and now you are introducing it back? Can we have a clear plan of action on this? Or is it just to stick with our guidelines? Is so there are more to change.

Yes, I'm trying to correct my early patch and trying to stick with the guidelines.

My plan is to move away from Optional::{hasValue,getValue} while sticking to the coding style of respective subprojects.

This means that for flang, hasValue will be dropped inside control-flow conditions and converted to has_value outside control-flow conditions. getValue will be converted to '*' where the protection is obvious and .value() otherwise.

clementval accepted this revision.Jun 25 2022, 1:15 PM

Ok thanks for the explanation and sticking to our previous guidelines. Lgtm.

This revision is now accepted and ready to land.Jun 25 2022, 1:15 PM
This revision was automatically updated to reflect the committed changes.