This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add llvm-derefencing-dyn-cast check
Needs ReviewPublic

Authored by njames93 on Aug 6 2022, 2:06 AM.

Details

Summary

Add a check that aims to prevent dereferencing casts that may return nullptr.

Diff Detail

Event Timeline

njames93 created this revision.Aug 6 2022, 2:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2022, 2:06 AM
njames93 requested review of this revision.Aug 6 2022, 2:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2022, 2:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I had thought about merging this into the prefer-isa-or-dyn-cast in conditionals check, however there just isn't enough cross-over between the 2 and the names wouldn't really match up with what each part of the check does.
There could be merit in merging them both into a new check and removing the old one, however I feel that could cause disruption for downstream users.

LegalizeAdulthood resigned from this revision.Mar 29 2023, 8:28 AM