[TargetVersion] Only enable on RISC-V and AArch64 (#115991)
[llvm-project.git] / clang-tools-extra / clang-tidy / bugprone / UniquePtrArrayMismatchCheck.cpp
blob8d09b4b320c2cb5ec88c7b04435079d63256fa92
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 //===----------------------------------------------------------------------===//
9 #include "UniquePtrArrayMismatchCheck.h"
11 using namespace clang::ast_matchers;
13 namespace clang::tidy::bugprone {
15 UniquePtrArrayMismatchCheck::UniquePtrArrayMismatchCheck(
16 StringRef Name, ClangTidyContext *Context)
17 : SmartPtrArrayMismatchCheck(Name, Context, "unique") {}
19 UniquePtrArrayMismatchCheck::SmartPtrClassMatcher
20 UniquePtrArrayMismatchCheck::getSmartPointerClassMatcher() const {
21 auto DeleterDecl = classTemplateSpecializationDecl(
22 hasName("::std::default_delete"), templateArgumentCountIs(1),
23 hasTemplateArgument(0, templateArgument(refersToType(
24 qualType(equalsBoundNode(PointerTypeN))))));
25 return classTemplateSpecializationDecl(
26 hasName("::std::unique_ptr"), templateArgumentCountIs(2),
27 hasTemplateArgument(
28 0, templateArgument(refersToType(qualType().bind(PointerTypeN)))),
29 hasTemplateArgument(1, templateArgument(refersToType(
30 qualType(hasDeclaration(DeleterDecl))))));
33 } // namespace clang::tidy::bugprone