This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] hoist nullptr checks. NFC
ClosedPublic

Authored by nickdesaulniers on May 19 2019, 7:32 PM.

Details

Summary

This was flagged in https://www.viva64.com/en/b/0629/ under "Snippet No.
15" (see under #13). It looks like PVS studio flags nullptr checks where
the ptr is used inbetween creation and checking against nullptr.

Diff Detail

Repository
rL LLVM

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2019, 7:32 PM
JDevlieghere accepted this revision.May 19 2019, 10:36 PM

Thanks, LGTM

This revision is now accepted and ready to land.May 19 2019, 10:36 PM
This revision was automatically updated to reflect the committed changes.

Is there a test case for this codepath? Or should it be an assertion instead?

Is there a test case for this codepath? Or should it be an assertion instead?

I think we should keep the check as is, it could be tickled by incorrect use of the API but a unittest should be able to exercise it fairly easily.