Author: alexfh Date: Mon May 22 08:58:57 2017 New Revision: 303552 URL: http://llvm.org/viewvc/llvm-project?rev=303552&view=rev Log: [clang-tidy] readability-redundant-declaration false positive for defaulted function
Summary: ``` template <class T> struct C { C(); }; template <class T> C<T>::C() = default; ``` Causes a readability-redundant-declaration diagnostic. This is caused by `isDefinition` not matching defaulted functions. Reviewers: alexfh, danielmarjamaki Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Patch by Florian Gross! Differential Revision: https://reviews.llvm.org/D33358 Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp?rev=303552&r1=303551&r2=303552&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp Mon May 22 08:58:57 2017 @@ -19,11 +19,12 @@ namespace tidy { namespace readability { void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) { - auto UnlessDefinition = unless(isDefinition()); - Finder->addMatcher(namedDecl(anyOf(varDecl(UnlessDefinition), - functionDecl(UnlessDefinition))) - .bind("Decl"), - this); + Finder->addMatcher( + namedDecl( + anyOf(varDecl(unless(isDefinition())), + functionDecl(unless(anyOf(isDefinition(), isDefaulted()))))) + .bind("Decl"), + this); } void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) { Modified: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp?rev=303552&r1=303551&r2=303552&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp Mon May 22 08:58:57 2017 @@ -34,3 +34,11 @@ struct C { static int I; }; int C::I; + +template <class T> +struct C2 { + C2(); +}; + +template <class T> +C2<T>::C2() = default; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits