fgross created this revision. Herald added a subscriber: xazax.hun. 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. https://reviews.llvm.org/D33358 Files: clang-tidy/readability/RedundantDeclarationCheck.cpp test/clang-tidy/readability-redundant-declaration.cpp Index: test/clang-tidy/readability-redundant-declaration.cpp =================================================================== --- test/clang-tidy/readability-redundant-declaration.cpp +++ test/clang-tidy/readability-redundant-declaration.cpp @@ -34,3 +34,11 @@ static int I; }; int C::I; + +template <class T> +struct C2 { + C2(); +}; + +template <class T> +C2<T>::C2() = default; Index: clang-tidy/readability/RedundantDeclarationCheck.cpp =================================================================== --- clang-tidy/readability/RedundantDeclarationCheck.cpp +++ clang-tidy/readability/RedundantDeclarationCheck.cpp @@ -19,11 +19,12 @@ 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) {
Index: test/clang-tidy/readability-redundant-declaration.cpp =================================================================== --- test/clang-tidy/readability-redundant-declaration.cpp +++ test/clang-tidy/readability-redundant-declaration.cpp @@ -34,3 +34,11 @@ static int I; }; int C::I; + +template <class T> +struct C2 { + C2(); +}; + +template <class T> +C2<T>::C2() = default; Index: clang-tidy/readability/RedundantDeclarationCheck.cpp =================================================================== --- clang-tidy/readability/RedundantDeclarationCheck.cpp +++ clang-tidy/readability/RedundantDeclarationCheck.cpp @@ -19,11 +19,12 @@ 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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits