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

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


thyecust created this revision.
thyecust added a reviewer: clang-tools-extra.
thyecust added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, 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:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145031

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: D145031.501381.patch
Type: text/x-patch
Size: 615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230301/6f745760/attachment.bin>


More information about the cfe-commits mailing list