Page MenuHomePhabricator

[flang] Don't use Optional::hasValue (NFC)
ClosedPublic

Authored by kazu on Jun 26 2022, 8:33 PM.

Details

Summary

Flang C++ Style Guide tells us to avoid .has_value() in the predicate
expressions of control flow statements. I am treating ternary
expressions as control flow statements for the purpose of this patch.

Diff Detail

Event Timeline

kazu created this revision.Jun 26 2022, 8:33 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 26 2022, 8:33 PM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
kazu requested review of this revision.Jun 26 2022, 8:33 PM
kazu added a comment.Jun 27 2022, 10:45 PM

Friendly ping. Thanks!

Hi @kazu, thanks for making a review and making the code style consistent. It seems part of the change is breaking builds (see bots).

flang/lib/Optimizer/Dialect/FIROps.cpp
1108

This is breaking the build bots:

/var/lib/buildkite-agent/builds/llvm-project/flang/lib/Optimizer/Dialect/FIROps.cpp:1077:7: error: value of type 'mlir::OptionalParseResult' is not contextually convertible to 'bool'
  if (parseResult && failed(*parseResult))
      ^~~~~~~~~~~

Same below in /var/lib/buildkite-agent/builds/llvm-project/flang/lib/Optimizer/Dialect/FIROps.cpp:1259:9

kazu updated this revision to Diff 440635.Jun 28 2022, 8:29 AM

Updated FIROps.cpp and Dialect/FIROps.cpp.

kazu added a comment.Jun 28 2022, 8:30 AM

Hi @kazu, thanks for making a review and making the code style consistent. It seems part of the change is breaking builds (see bots).

Oops. Thank you for pointing out the breakage. It looks like I temporarily disabled flang, and I was testing anything. Please take a look again.

jeanPerier accepted this revision.Jun 29 2022, 4:43 AM

Thanks

This revision is now accepted and ready to land.Jun 29 2022, 4:43 AM
This revision was automatically updated to reflect the committed changes.