This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix `LoweringBridge::validModule`
ClosedPublic

Authored by awarzynski on Feb 14 2022, 4:22 AM.

Details

Summary

This patch updates validModule not to use getModule. getModule
will dereference module, but that will lead to a seg-fault if module
is a nullptr.

Diff Detail

Event Timeline

awarzynski created this revision.Feb 14 2022, 4:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 14 2022, 4:22 AM
awarzynski requested review of this revision.Feb 14 2022, 4:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 14 2022, 4:22 AM
schweitz added inline comments.Feb 14 2022, 9:04 AM
flang/include/flang/Lower/Bridge.h
87

Someone else called this "Yoda style". But their question remains: why use it?

awarzynski added inline comments.Feb 14 2022, 10:06 AM
flang/include/flang/Lower/Bridge.h
87

Yoda Condition ;-)

Tl:Dr With this style, you will never write var = 0 instead of var == 0 (compilers will complain about 0 = var, but not about 0 == var). Happy to change to module != nullptr if that's what you prefer.

schweitz added inline comments.Feb 14 2022, 10:58 AM
flang/include/flang/Lower/Bridge.h
87

I expect that module != nullptr wouldn't attract any attention. ;)

Swap the comparison

schweitz accepted this revision.Feb 15 2022, 3:38 PM
This revision is now accepted and ready to land.Feb 15 2022, 3:38 PM
This revision was automatically updated to reflect the committed changes.