This is an archive of the discontinued LLVM Phabricator instance.

[flang] Restore checking for some optional values before use
ClosedPublic

Authored by klausler on Dec 19 2022, 12:47 PM.

Details

Summary

Recent commits (2098ad7f00324ee0f2a6538f418a6f81dfdd2edb and
15a9a72ee68166c0cff3f036cacd3c82be66c729) replaced usage of "o.value()"
on optionals with "*o". Those optional values are expected to be
present, but now, if they're not, compilation will proceed with
garbage data rather than crashing on an uncaught exception.
Add asserts for presence to restore the previous level of safety.

Diff Detail

Event Timeline

klausler created this revision.Dec 19 2022, 12:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2022, 12:47 PM
klausler requested review of this revision.Dec 19 2022, 12:47 PM
vzakhari accepted this revision.Dec 19 2022, 12:49 PM
vzakhari added a subscriber: vzakhari.

LGTM

This revision is now accepted and ready to land.Dec 19 2022, 12:49 PM
sscalpone accepted this revision.Dec 19 2022, 1:13 PM
clementval accepted this revision.Dec 19 2022, 1:24 PM
klausler updated this revision to Diff 484074.Dec 19 2022, 2:32 PM

Update patch.

jeanPerier accepted this revision.Dec 19 2022, 11:50 PM
jeanPerier added inline comments.Dec 19 2022, 11:53 PM
flang/lib/Lower/ConvertExpr.cpp
3673

lhsLoad.has_value()

klausler updated this revision to Diff 485618.Dec 29 2022, 8:17 AM

Incorporate Jean's suggested change.

Are asserts the right solution or do you need control flow to check whether optionals have a value?