summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h4
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp1
3 files changed, 8 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
index 5d93357e398..b2aff4d1471 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -30,7 +30,8 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
// than one shadow.
if (Using->shadow_size() != 1)
return;
- const auto* TargetDecl = Using->shadow_begin()->getTargetDecl();
+ const auto *TargetDecl =
+ Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
// FIXME: Handle other target types.
if (!isa<RecordDecl>(TargetDecl))
@@ -52,8 +53,9 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
// FIXME: This currently doesn't look at whether the type reference is
// actually found with the help of the using declaration.
if (const auto *Used = Result.Nodes.getNodeAs<NamedDecl>("used")) {
- if (FoundDecls.find(Used) != FoundDecls.end())
- FoundDecls[Used] = nullptr;
+ auto I = FoundDecls.find(Used->getCanonicalDecl());
+ if (I != FoundDecls.end())
+ I->second = nullptr;
}
}
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h
index 9c899e8f178..dc8fb88c34e 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -30,8 +30,8 @@ public:
void onEndOfTranslationUnit() override;
private:
- llvm::DenseMap<const NamedDecl*, const UsingDecl*> FoundDecls;
- llvm::DenseMap<const NamedDecl*, CharSourceRange> FoundRanges;
+ llvm::DenseMap<const Decl*, const UsingDecl*> FoundDecls;
+ llvm::DenseMap<const Decl*, CharSourceRange> FoundRanges;
};
} // namespace misc
diff --git a/clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp b/clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
index 110c1b46fbb..053e65d43fd 100644
--- a/clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
@@ -6,6 +6,7 @@ namespace n {
class A;
class B;
class C;
+class D;
class D { public: static int i; };
}
OpenPOWER on IntegriCloud