[PATCH] D145030: [clang-tidy] use isConvertingConstructor to simplify code

thyecust via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 28 22:39:38 PST 2023


thyecust created this revision.
thyecust added a reviewer: clang-tools-extra.
thyecust added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, mgehre, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
thyecust requested review of this revision.
Herald added a subscriber: cfe-commits.

isConvertingConstructor() is a better API.

https://google.github.io/styleguide/cppguide.html#Implicit_Conversions:

> constructors that are callable with a single argument, must be marked explicit in the class definition.




Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D145030

Files:
  clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp


Index: clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
+++ clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
@@ -97,8 +97,7 @@
   }
 
   const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
-  if (Ctor->isOutOfLine() || Ctor->getNumParams() == 0 ||
-      Ctor->getMinRequiredArguments() > 1)
+  if (Ctor->isOutOfLine() || Ctor->isConvertingConstructor(true))
     return;
 
   bool TakesInitializerList = isStdInitializerList(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145030.501377.patch
Type: text/x-patch
Size: 615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230301/e865b8f6/attachment-0001.bin>


More information about the cfe-commits mailing list