[PATCH] D20857: [clang-tidy] Add modernize-explicit-operator-bool check.
Murray Cumming via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 22 02:38:27 PDT 2016
murrayc added inline comments.
================
Comment at: clang-tidy/modernize/ExplicitOperatorBoolCheck.cpp:38
@@ +37,3 @@
+ Finder->addMatcher(
+ cxxConversionDecl(returns(booleanType()), unless(isExplicit()))
+ .bind("operator-bool"),
----------------
alexfh wrote:
> Please merge these two matchers to avoid repeated work. Something along the lines of:
>
> cxxConversionDecl(unless(isExplicit()),
> anyOf(cxxConversionDecl(returns(booleanType())).bind("operator-bool"),
> cxxConversionDecl(returns(pointerType(pointee(isConstQualified(), voidType()))).bind("operator-void-pointer"))));
It seems that I can't pass cxxConversionDecls to anyOf(). I can pass anyOf to cxxConversionDecl, but then I don't see how to bind() to the two kinds of declaration separately:
Finder->addMatcher(
cxxConversionDecl(
anyOf(returns(booleanType()),
returns(pointerType(pointee(isConstQualified(), voidType())))),
unless(isExplicit())),
this);
I also wonder if I'll be able to combine them while keeping the check for WarnOnOperatorVoidPointer, to avoid unnecessary work when that is disabled. (And I still wonder if you even want the check for operator void*.)
https://reviews.llvm.org/D20857
More information about the cfe-commits
mailing list