clang-tools 20.0.0git
SharedPtrArrayMismatchCheck.cpp
Go to the documentation of this file.
1//===--- SharedPtrArrayMismatchCheck.cpp - clang-tidy ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11using namespace clang::ast_matchers;
12
13namespace clang::tidy::bugprone {
14
16 StringRef Name, ClangTidyContext *Context)
17 : SmartPtrArrayMismatchCheck(Name, Context, "shared") {}
18
21 return classTemplateSpecializationDecl(
22 hasName("::std::shared_ptr"), templateArgumentCountIs(1),
23 hasTemplateArgument(
24 0, templateArgument(refersToType(qualType().bind(PointerTypeN)))));
25}
26
27} // namespace clang::tidy::bugprone
llvm::SmallString< 256U > Name
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
SmartPtrClassMatcher getSmartPointerClassMatcher() const override
Returns matcher that match with different smart pointer classes.
SharedPtrArrayMismatchCheck(StringRef Name, ClangTidyContext *Context)
Find constructions of smart (unique or shared) pointers where the pointer is declared with non-array ...
ast_matchers::internal::BindableMatcher< Decl > SmartPtrClassMatcher