1 | //===--- UniquePtrArrayMismatchCheck.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 | |
9 | #include "UniquePtrArrayMismatchCheck.h" |
10 | |
11 | using namespace clang::ast_matchers; |
12 | |
13 | namespace clang::tidy::bugprone { |
14 | |
15 | UniquePtrArrayMismatchCheck::UniquePtrArrayMismatchCheck( |
16 | StringRef Name, ClangTidyContext *Context) |
17 | : SmartPtrArrayMismatchCheck(Name, Context, "unique" ) {} |
18 | |
19 | UniquePtrArrayMismatchCheck::SmartPtrClassMatcher |
20 | UniquePtrArrayMismatchCheck::getSmartPointerClassMatcher() const { |
21 | auto DeleterDecl = classTemplateSpecializationDecl( |
22 | hasName(Name: "::std::default_delete" ), templateArgumentCountIs(N: 1), |
23 | hasTemplateArgument(N: 0, InnerMatcher: templateArgument(refersToType( |
24 | InnerMatcher: qualType(equalsBoundNode(ID: PointerTypeN)))))); |
25 | return classTemplateSpecializationDecl( |
26 | hasName(Name: "::std::unique_ptr" ), templateArgumentCountIs(N: 2), |
27 | hasTemplateArgument( |
28 | N: 0, InnerMatcher: templateArgument(refersToType(InnerMatcher: qualType().bind(ID: PointerTypeN)))), |
29 | hasTemplateArgument(N: 1, InnerMatcher: templateArgument(refersToType( |
30 | InnerMatcher: qualType(hasDeclaration(InnerMatcher: DeleterDecl)))))); |
31 | } |
32 | |
33 | } // namespace clang::tidy::bugprone |
34 | |