From 2644cae3d5708149df916ac60073d28dea87880e Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Mon, 3 Aug 2015 22:02:08 +0000 Subject: [PATCH] [clang-tidy] Improve the misc-unused-alias-decl message "this namespace alias decl is unused" -> "namespace alias decl '...' is unused" llvm-svn: 243906 --- clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp | 5 +++-- clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.h | 2 +- clang-tools-extra/test/clang-tidy/misc-unused-alias-decls.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp index 0b59692..80e4861 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp @@ -30,7 +30,7 @@ void UnusedAliasDeclsCheck::registerMatchers(MatchFinder *Finder) { } void UnusedAliasDeclsCheck::check(const MatchFinder::MatchResult &Result) { - if (const auto *AliasDecl = Result.Nodes.getNodeAs("alias")) { + if (const auto *AliasDecl = Result.Nodes.getNodeAs("alias")) { FoundDecls[AliasDecl] = CharSourceRange::getCharRange( AliasDecl->getLocStart(), Lexer::findLocationAfterToken( @@ -52,7 +52,8 @@ void UnusedAliasDeclsCheck::onEndOfTranslationUnit() { for (const auto &FoundDecl : FoundDecls) { if (!FoundDecl.second.isValid()) continue; - diag(FoundDecl.first->getLocation(), "this namespace alias decl is unused") + diag(FoundDecl.first->getLocation(), "namespace alias decl '%0' is unused") + << FoundDecl.first->getName() << FixItHint::CreateRemoval(FoundDecl.second); } } diff --git a/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.h b/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.h index 3cbaecd..770038f 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.h +++ b/clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.h @@ -25,7 +25,7 @@ public: void onEndOfTranslationUnit() override; private: - llvm::DenseMap FoundDecls; + llvm::DenseMap FoundDecls; }; } // namespace tidy diff --git a/clang-tools-extra/test/clang-tidy/misc-unused-alias-decls.cpp b/clang-tools-extra/test/clang-tidy/misc-unused-alias-decls.cpp index 01d6d9a..46527e4 100644 --- a/clang-tools-extra/test/clang-tidy/misc-unused-alias-decls.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-unused-alias-decls.cpp @@ -6,7 +6,7 @@ class C {}; } namespace unused_alias = ::my_namespace; // eol-comments aren't removed (yet) -// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: this namespace alias decl is unused +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace alias decl 'unused_alias' is unused // CHECK-FIXES: {{^}}// eol-comments aren't removed (yet) namespace used_alias = ::my_namespace; -- 2.7.4