This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Don't emit misc-unused-using-decl warnings for header files.
ClosedPublic

Authored by hokein on Jan 3 2023, 6:13 AM.

Details

Summary

Using decls in header files are special, usually as part of the
public API, the check should not emit warnings on these.

The check already detects unused using-decls which are in the current main
file, but if the main file happens to be a header file, we still
emit warnings, this patch suppresses that.

Diff Detail

Event Timeline

hokein created this revision.Jan 3 2023, 6:13 AM
Herald added a project: Restricted Project. · View Herald Transcript
hokein requested review of this revision.Jan 3 2023, 6:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2023, 6:13 AM
Eugene.Zelenko added inline comments.
clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst
26

Please use single back-ticks for option values.

Actually this is second patch with similar functionality during last month and I think this option should be shared between all checks.

ymandel accepted this revision.Jan 3 2023, 8:01 AM

Thanks!

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

nit: no need for braces on the if statement.

clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst
26

Eugene -- are you suggesting that is a blocker on this patch, or just a good idea for clang-tidy in general?

27
This revision is now accepted and ready to land.Jan 3 2023, 8:01 AM
Eugene.Zelenko added inline comments.Jan 3 2023, 8:06 AM
clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst
26

Sure, it'll be better to do this as separate patch, but this should be done at some point. It;s both code duplication and more complex complex setup for users.

carlosgalvezp added inline comments.Jan 3 2023, 9:30 AM
clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst
26

I'm planning to add the suggested functionality in a separate patch when I find some time. Can fix existing checks as well.

hokein updated this revision to Diff 486191.Jan 4 2023, 1:07 AM
hokein marked 2 inline comments as done.

address comments

clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst
26

Thanks.

I changed to use , for option values in this patch (I thought ,, and ; are both fine, if , is more preferred, we should probably change defaultImplementationFileExtensions, and StringRef defaultHeaderFileExtensions functions in FileExtensionsUtils.h, they use ;, I just followed their way).

This revision was landed with ongoing or failed builds.Jan 4 2023, 1:11 AM
This revision was automatically updated to reflect the committed changes.