This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix a false positive in unused-using-decl check.
ClosedPublic

Authored by hokein on Aug 29 2019, 7:40 AM.

Details

Reviewers
gribozavr
Summary

The previous matcher "hasAnyTemplateArgument(templateArgument())" only
matches the first template argument, but the check wants to iterate all
template arguments. This patch fixes this.

Also some refactorings in this patch (to make the code reusable).

Event Timeline

hokein created this revision.Aug 29 2019, 7:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2019, 7:40 AM
Herald added a subscriber: xazax.hun. · View Herald Transcript
gribozavr added inline comments.Sep 2 2019, 2:00 AM
clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
212

It is very unclear what this test does, if I didn't know about this bug. Could you add a comment?

hokein updated this revision to Diff 218422.Sep 3 2019, 3:16 AM
hokein marked an inline comment as done.

Use a matcher to catch all template arguments

hokein updated this revision to Diff 218423.Sep 3 2019, 3:18 AM

minor fix

gribozavr added inline comments.Sep 3 2019, 4:27 AM
clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
103

Please move the comment below the lambda. The lambda is not doing what this comment says.

136

Could you add a test for this case?

hokein updated this revision to Diff 218450.Sep 3 2019, 7:02 AM
hokein marked 3 inline comments as done.

Update the comment.

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
103

I think the comment is pretty old (it was added in the first patch, but the check has been evolved a lot). I updated the comment here.

136

This is already covered by the existing test case a.func2<int, ff>(t3); -- in this patch, we change the matcher of callExpr on Line 63, and the callback of it now runs into this codepath (previously it falls into the if (const auto *Used = Result.Nodes.getNodeAs<NamedDecl>("used") branch above).

gribozavr accepted this revision.Sep 3 2019, 7:06 AM
This revision is now accepted and ready to land.Sep 3 2019, 7:06 AM
hokein closed this revision.Sep 3 2019, 7:23 AM

committed in rL370760