This is an archive of the discontinued LLVM Phabricator instance.

Initial version of misc-unused-using-decl check
ClosedPublic

Authored by djasper on Apr 19 2016, 5:21 AM.

Details

Reviewers
alexfh

Diff Detail

Event Timeline

djasper updated this revision to Diff 54178.Apr 19 2016, 5:21 AM
djasper retitled this revision from to Initial version of misc-unused-using-decl check.
djasper updated this object.
djasper added a reviewer: alexfh.
djasper added a subscriber: cfe-commits.
alexfh edited edge metadata.Apr 19 2016, 6:02 AM

Awesome! Thank you for tackling this! A few comments.

clang-tidy/misc/CMakeLists.txt
39

Please fix file sorting around the new file.

clang-tidy/misc/MiscTidyModule.cpp
123

I think, all "misc-unused-" checks except for the "misc-unused-raii" (which finds actual bugs) mostly relate to readability. I suggest placing the new check to readability/ and we'll then move the other two "misc-unused-" checks there as well.

clang-tidy/misc/UnusedUsingDeclsCheck.cpp
24

Why is it necessarily a recordType? How about typedefs and enums?

clang-tidy/misc/UnusedUsingDeclsCheck.h
33

I'm not sure how the llvm/ADT/DenseMap.h header is pulled here, but DenseMap is not even used in ClangTidy.h, so this transitive inclusion is rather brittle. Please include llvm/ADT/DenseMap.h directly.

docs/clang-tidy/checks/misc-unused-using-decls.rst
7

Add an example, please.

djasper marked 3 inline comments as done.Apr 19 2016, 6:15 AM
djasper added inline comments.
clang-tidy/misc/MiscTidyModule.cpp
123

I am not really certain that "readability" is a reasonable category for unused things. Maybe unused should be its own category? At any rate, I think we should move all of them at the same time and not now go ahead and create a weird intermediate state.

clang-tidy/misc/UnusedUsingDeclsCheck.cpp
24

I'd like to handle those as a follow-up. We only track using declarations of Records at the moment in the callback, too.

djasper updated this revision to Diff 54183.Apr 19 2016, 6:15 AM
djasper edited edge metadata.
alexfh accepted this revision.Apr 19 2016, 6:48 AM
alexfh edited edge metadata.

LG with one nit.

Thank you!

clang-tidy/misc/MiscTidyModule.cpp
123

Fair enough. Let's go this way then.

clang-tidy/misc/UnusedUsingDeclsCheck.cpp
67

FoundDecls should be cleared at the end. There are some cases when a check can be used multiple times (e.g. in unit tests). Though we're not adding unit tests here, I think, we shouldn't hide this kind of a surprise in the code ;)

This revision is now accepted and ready to land.Apr 19 2016, 6:48 AM
alexfh closed this revision.Apr 26 2016, 2:47 AM

This seems to have been committed as r266735.