From dd0c0ba82c8c12dad6b07dd825f1c39e959939d7 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Wed, 28 Dec 2016 13:48:03 +0000 Subject: [PATCH] [clang-tidy] google-explicit-constructor: ignore compiler-generated conversion operators. llvm-svn: 290668 --- .../clang-tidy/google/ExplicitConstructorCheck.cpp | 7 +++++-- .../test/clang-tidy/google-explicit-constructor.cpp | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp index ca81de1dcd2e..1257d100d3d5 100644 --- a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp @@ -26,8 +26,11 @@ void ExplicitConstructorCheck::registerMatchers(MatchFinder *Finder) { return; Finder->addMatcher(cxxConstructorDecl(unless(isInstantiated())).bind("ctor"), this); - Finder->addMatcher(cxxConversionDecl(unless(isExplicit())).bind("conversion"), - this); + Finder->addMatcher( + cxxConversionDecl(unless(isExplicit()), // Already marked explicit. + unless(isImplicit())) // Compiler-generated. + .bind("conversion"), + this); } // Looks for the token matching the predicate and returns the range of the found diff --git a/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp b/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp index f8a154e559dd..6cc3435b9b88 100644 --- a/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp @@ -80,6 +80,10 @@ struct B { // CHECK-FIXES: {{^ }}B(::std::initializer_list &&list6) {} }; +struct StructWithFnPointer { + void (*f)(); +} struct_with_fn_pointer = {[] {}}; + using namespace std; struct C {