Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp =================================================================== --- clang-tidy/misc/UnusedUsingDeclsCheck.cpp +++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp @@ -19,12 +19,13 @@ namespace misc { // A function that helps to tell whether a TargetDecl in a UsingDecl will be -// checked. Only variable, function, function template, class template and class -// are considered. +// checked. Only variable, function, function template, class template, class, +// enum declaration and enum constant declaration are considered. static bool ShouldCheckDecl(const Decl *TargetDecl) { return isa(TargetDecl) || isa(TargetDecl) || isa(TargetDecl) || isa(TargetDecl) || - isa(TargetDecl); + isa(TargetDecl) || isa(TargetDecl) || + isa(TargetDecl); } void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) { @@ -91,6 +92,8 @@ removeFromFoundDecls(FD); } else if (const auto *VD = dyn_cast(DRE->getDecl())) { removeFromFoundDecls(VD); + } else if (const auto *ECD = dyn_cast(DRE->getDecl())) { + removeFromFoundDecls(ECD); } } // Check the uninstantiated template function usage. Index: test/clang-tidy/misc-unused-using-decls.cpp =================================================================== --- test/clang-tidy/misc-unused-using-decls.cpp +++ test/clang-tidy/misc-unused-using-decls.cpp @@ -43,7 +43,14 @@ }; extern ostream cout; ostream &endl(ostream &os); -} + +enum Color { + Green, + Red, + Yellow +}; + +} // namespace n // ----- Using declarations ----- // eol-comments aren't removed (yet) @@ -119,6 +126,12 @@ using n::H; } +using n::Color; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Color' is unused +using n::Green; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused +using n::Red; + // ----- Usages ----- void f(B b); void g() { @@ -131,4 +144,5 @@ UsedFunc(); UsedTemplateFunc(); cout << endl; + int t = Red; }