diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp index 5244aa60ee6a..a690e447b84b 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp @@ -24,7 +24,8 @@ UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context) void UseUsingCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus11) return; - Finder->addMatcher(typedefDecl().bind("typedef"), this); + Finder->addMatcher(typedefDecl(unless(isInstantiated())).bind("typedef"), + this); } // Checks if 'typedef' keyword can be removed - we do it only if diff --git a/clang-tools-extra/test/clang-tidy/modernize-use-using.cpp b/clang-tools-extra/test/clang-tidy/modernize-use-using.cpp index e8f4958f9516..efa4030d001e 100644 --- a/clang-tools-extra/test/clang-tidy/modernize-use-using.cpp +++ b/clang-tools-extra/test/clang-tidy/modernize-use-using.cpp @@ -162,3 +162,24 @@ typedef unsigned Map[lol]; typedef void (*fun_type)(); // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' // CHECK-FIXES: using fun_type = void (*)(); + +namespace template_instantiations { +template +class C { + protected: + typedef C super; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef' + // CHECK-FIXES: using super = C; + virtual void f(); + +public: + virtual ~C(); +}; + +class D : public C { + void f() override { super::f(); } +}; +class E : public C { + void f() override { super::f(); } +}; +}