Author: alexfh Date: Fri Dec 30 07:25:03 2016 New Revision: 290753 URL: http://llvm.org/viewvc/llvm-project?rev=290753&view=rev Log: [clang-tidy] google-explicit-constructor: ignore template instantiations
Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?rev=290753&r1=290752&r2=290753&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Fri Dec 30 07:25:03 2016 @@ -27,8 +27,10 @@ void ExplicitConstructorCheck::registerM Finder->addMatcher(cxxConstructorDecl(unless(isInstantiated())).bind("ctor"), this); Finder->addMatcher( - cxxConversionDecl(unless(isExplicit()), // Already marked explicit. - unless(isImplicit())) // Compiler-generated. + cxxConversionDecl(unless(anyOf(isExplicit(), // Already marked explicit. + isImplicit(), // Compiler-generated. + isInstantiated()))) + .bind("conversion"), this); } Modified: clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp?rev=290753&r1=290752&r2=290753&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp Fri Dec 30 07:25:03 2016 @@ -138,3 +138,35 @@ void f(std::initializer_list<int> list) E<decltype(list)> e(list); E<int> e2(list); } + +template <typename T> +struct F {}; + +template<typename T> +struct G { + operator bool() const; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator bool' must be marked + // CHECK-FIXES: {{^}} explicit operator bool() const; + operator F<T>() const; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator F<type-parameter-0-0>' must be marked + // CHECK-FIXES: {{^}} explicit operator F<T>() const; + template<typename U> + operator F<U>*() const; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator F<type-parameter-1-0> *' must be marked + // CHECK-FIXES: {{^}} explicit operator F<U>*() const; +}; + +void f2() { + G<int> a; + (void)(F<int>)a; + if (a) {} + (void)(F<int>*)a; + (void)(F<int*>*)a; + + G<double> b; + (void)(F<double>)b; + if (b) {} + (void)(F<double>*)b; + (void)(F<double*>*)b; + +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits