This is an archive of the discontinued LLVM Phabricator instance.

[NFC][Clang] Fix static analyzer concern about null value dereference
ClosedPublic

Authored by eandrews on Aug 8 2023, 4:26 PM.

Details

Summary

InterfacePointerType is dereferenced and should not be null.

Diff Detail

Event Timeline

eandrews created this revision.Aug 8 2023, 4:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2023, 4:26 PM
eandrews requested review of this revision.Aug 8 2023, 4:26 PM
This revision is now accepted and ready to land.Aug 9 2023, 4:20 AM
tahonermann added inline comments.Aug 9 2023, 8:44 AM
clang/lib/CodeGen/CGObjC.cpp
222–223

The previous code included a guarantee that InterfacePointerType->getInterfaceType() is non-null and this change loses that assurance. Presumably, we never ran into a violation of that guarantee in the past (since a SIGSEGV would likely have occurred below otherwise), but perhaps we should consider an assertion to ensure that guarantee is still met.

eandrews added inline comments.Aug 9 2023, 10:10 AM
clang/lib/CodeGen/CGObjC.cpp
222–223

Hmmm... I guess in that case it was just make more sense to keep the old code and add an assert for InterfacePointerType?

eandrews marked an inline comment as not done.Aug 9 2023, 10:10 AM
tahonermann added inline comments.Aug 9 2023, 11:52 AM
clang/lib/CodeGen/CGObjC.cpp
222–223

Ah, yes, I think that is a better approach!

eandrews updated this revision to Diff 548789.Aug 9 2023, 3:31 PM

Applied review comments to use an assert instead

tahonermann accepted this revision.Aug 9 2023, 7:36 PM

Looks good to me. Thanks, Elizabeth!

Pre-merge check fails are unrelated - fatal error C1060: compiler is out of heap space

This revision was landed with ongoing or failed builds.Aug 14 2023, 7:20 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 7:20 AM