Author: alexfh Date: Thu Nov 22 08:10:18 2018 New Revision: 347470 URL: http://llvm.org/viewvc/llvm-project?rev=347470&view=rev Log: [clang-tidy] Ignore template instantiations in modernize-use-using
The test I'm adding passes without the change due to the deduplication logic in ClangTidyDiagnosticConsumer::take(). However this bug manifests in our internal integration with clang-tidy. I've verified the fix by locally changing LessClangTidyError to consider replacements. Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp?rev=347470&r1=347469&r2=347470&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp Thu Nov 22 08:10:18 2018 @@ -24,7 +24,8 @@ UseUsingCheck::UseUsingCheck(StringRef N 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 Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp?rev=347470&r1=347469&r2=347470&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp Thu Nov 22 08:10:18 2018 @@ -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 <typename T> +class C { + protected: + typedef C<T> super; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef' + // CHECK-FIXES: using super = C<T>; + virtual void f(); + +public: + virtual ~C(); +}; + +class D : public C<D> { + void f() override { super::f(); } +}; +class E : public C<E> { + void f() override { super::f(); } +}; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits