summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2016-05-18 11:49:34 +0000
committerHaojian Wu <hokein@google.com>2016-05-18 11:49:34 +0000
commit47ea5424d2d6c134bd21bfdf6f8d9b6197022805 (patch)
tree228a7aae035253da3398c3b2d2bbee05fcd4474a /clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
parent4df2e14dce298f0f3d5d00bd6e640c46f0b42b41 (diff)
downloadbcm5719-llvm-47ea5424d2d6c134bd21bfdf6f8d9b6197022805.tar.gz
bcm5719-llvm-47ea5424d2d6c134bd21bfdf6f8d9b6197022805.zip
[clang-tidy] Fix a template function false positive in misc-unused-using-decls check.
Summary: Ignore warning uninstantiated template function usages. Reviewers: djasper, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20326 llvm-svn: 269906
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
index 5fbc041c32a..1e23f198d13 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,6 +10,7 @@
#include "UnusedUsingDeclsCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
#include "clang/Lex/Lexer.h"
using namespace clang::ast_matchers;
@@ -18,12 +19,20 @@ namespace clang {
namespace tidy {
namespace misc {
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedLookupExpr>
+ unresolvedLookupExpr;
+}
+
void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
Finder->addMatcher(loc(recordType(DeclMatcher)), this);
Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
Finder->addMatcher(declRefExpr().bind("used"), this);
+ Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
+ this);
}
void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,13 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
removeFromFoundDecls(VD);
}
}
+ // Check the uninstantiated template function usage.
+ if (const auto *ULE = Result.Nodes.getNodeAs<UnresolvedLookupExpr>("used")) {
+ for (const NamedDecl* ND : ULE->decls()) {
+ if (const auto *USD = dyn_cast<UsingShadowDecl>(ND))
+ removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
+ }
+ }
}
void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
OpenPOWER on IntegriCloud