This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions
ClosedPublic

Authored by omtcyfz on Sep 24 2016, 3:25 PM.

Details

Summary

This patch extends clang-tidy's readability-redundant-smartptr-get to produce warnings for previously unsupported cases:

std::unique_ptr<void> ptr;
if (ptr.get())
if (ptr.get() == NULL)
if (ptr.get() != NULL)

This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug report opened by @Eugene.Zelenko.

However, there still are cases not detected by the check. They can be found in void Negative() function defined in test/clang-tidy/readability-redundant-smartptr-get.cpp.

Diff Detail

Repository
rL LLVM

Event Timeline

omtcyfz updated this revision to Diff 72395.Sep 24 2016, 3:25 PM
omtcyfz retitled this revision from to [clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions .
omtcyfz updated this object.
omtcyfz added reviewers: alexfh, klimek, ioeric.
omtcyfz added subscribers: cfe-commits, Eugene.Zelenko.
alexfh accepted this revision.Sep 24 2016, 7:49 PM
alexfh edited edge metadata.

LG. Thank you!

This revision is now accepted and ready to land.Sep 24 2016, 7:49 PM
alexfh added inline comments.Sep 24 2016, 7:54 PM
clang-tidy/readability/RedundantSmartptrGetCheck.cpp
64 ↗(On Diff #72395)

BTW, this can be done using hasAnyName.

omtcyfz updated this revision to Diff 72422.Sep 25 2016, 3:07 AM
omtcyfz edited edge metadata.
omtcyfz marked an inline comment as done.

Replace anyOf(hasName("..."), hasName("...")) with hasAnyName("...", "...").

Still LG.

Thank you! Landing the patch.

This revision was automatically updated to reflect the committed changes.