This is an archive of the discontinued LLVM Phabricator instance.

[NFC][CLANG] Fix Static Code Analyzer Concerns with dereference null return value in applyObjCTypeArgs()
ClosedPublic

Authored by Manna on Jun 1 2023, 7:45 PM.

Details

Summary

This patch uses castAs instead of getAs to resolve dereference issue with nullptr boundObjC when calling canAssignObjCInterfaces() or isObjCIdType() in applyObjCTypeArgs() since getAs returns nullptr.

Diff Detail

Event Timeline

Manna created this revision.Jun 1 2023, 7:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 7:45 PM
Manna requested review of this revision.Jun 1 2023, 7:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 7:45 PM
erichkeane accepted this revision.Jun 2 2023, 6:26 AM
erichkeane added inline comments.
clang/lib/Sema/SemaType.cpp
956

Note for future reviewers: This 'if' on both branches dereferences the boundObjC pointer. The true path is just below here, on 959. Second is in the condition inside of the else if on 961, canAssignObjCInterfaces immediately dereferences the parameters.

This revision is now accepted and ready to land.Jun 2 2023, 6:26 AM
Manna added inline comments.Jun 2 2023, 6:51 AM
clang/lib/Sema/SemaType.cpp
956

This 'if' on both branches dereferences the boundObjC pointer. The true path is just below here, on 959. Second is in the condition inside of the else if on 961, canAssignObjCInterfaces immediately dereferences the parameters.

Yes.

Thank you @erichkeane for reviews!