[clang-tools-extra] r243906 - [clang-tidy] Improve the misc-unused-alias-decl message
Alexander Kornienko
alexfh at google.com
Mon Aug 3 15:02:08 PDT 2015
Author: alexfh
Date: Mon Aug 3 17:02:08 2015
New Revision: 243906
URL: http://llvm.org/viewvc/llvm-project?rev=243906&view=rev
Log:
[clang-tidy] Improve the misc-unused-alias-decl message
"this namespace alias decl is unused" -> "namespace alias decl '...' is unused"
Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.h
clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp?rev=243906&r1=243905&r2=243906&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp Mon Aug 3 17:02:08 2015
@@ -30,7 +30,7 @@ void UnusedAliasDeclsCheck::registerMatc
}
void UnusedAliasDeclsCheck::check(const MatchFinder::MatchResult &Result) {
- if (const auto *AliasDecl = Result.Nodes.getNodeAs<Decl>("alias")) {
+ if (const auto *AliasDecl = Result.Nodes.getNodeAs<NamedDecl>("alias")) {
FoundDecls[AliasDecl] = CharSourceRange::getCharRange(
AliasDecl->getLocStart(),
Lexer::findLocationAfterToken(
@@ -52,7 +52,8 @@ void UnusedAliasDeclsCheck::onEndOfTrans
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);
}
}
Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.h?rev=243906&r1=243905&r2=243906&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.h Mon Aug 3 17:02:08 2015
@@ -25,7 +25,7 @@ public:
void onEndOfTranslationUnit() override;
private:
- llvm::DenseMap<const Decl *, CharSourceRange> FoundDecls;
+ llvm::DenseMap<const NamedDecl *, CharSourceRange> FoundDecls;
};
} // namespace tidy
Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp?rev=243906&r1=243905&r2=243906&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp Mon Aug 3 17:02:08 2015
@@ -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;
More information about the cfe-commits
mailing list