================
@@ -0,0 +1,475 @@
+//===--- UseSharedPtrArrayCheck.cpp - clang-tidy 
--------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "UseSharedPtrArrayCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+void UseSharedPtrArrayCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+      cxxConstructExpr(
+
+          hasType(qualType(hasDeclaration(
+              classTemplateSpecializationDecl(hasName("::std::shared_ptr"))))),
+
+          argumentCountIs(2),
+
+          hasArgument(
+              0, ignoringParenImpCasts(cxxNewExpr(isArray()).bind("newExpr"))),
+
+          anyOf(hasArgument(
+                    1, ignoringImplicit(
+                           cxxConstructExpr(
+                               
hasType(qualType(hasCanonicalType(hasDeclaration(
+                                   classTemplateSpecializationDecl(
+                                       hasName("::std::default_delete")))))))
+                               .bind("defaultDelete"))),
+
+                hasArgument(
+                    1, ignoringImplicit(lambdaExpr().bind("lambdaDeleter"))),
+
+                hasArgument(1, ignoringImplicit(declRefExpr(to(
+                                   functionDecl().bind("deleterFunction")))))))
----------------
zwuis wrote:

How about `hasArgumet(1, anyOf(...))`?

https://github.com/llvm/llvm-project/pull/199458
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to