clang-tools
20.0.0git
llvm-project
clang-tools-extra
clang-tidy
bugprone
UniquePtrArrayMismatchCheck.cpp
Go to the documentation of this file.
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(
"::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))))));
31
}
32
33
}
// namespace clang::tidy::bugprone
Name
llvm::SmallString< 256U > Name
Definition:
ChainedComparisonCheck.cpp:42
UniquePtrArrayMismatchCheck.h
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
clang::tidy::bugprone::SmartPtrArrayMismatchCheck
Find constructions of smart (unique or shared) pointers where the pointer is declared with non-array ...
Definition:
SmartPtrArrayMismatchCheck.h:19
clang::tidy::bugprone::SmartPtrArrayMismatchCheck::PointerTypeN
static const char PointerTypeN[]
Definition:
SmartPtrArrayMismatchCheck.h:40
clang::tidy::bugprone::SmartPtrArrayMismatchCheck::SmartPtrClassMatcher
ast_matchers::internal::BindableMatcher< Decl > SmartPtrClassMatcher
Definition:
SmartPtrArrayMismatchCheck.h:32
clang::tidy::bugprone::UniquePtrArrayMismatchCheck::UniquePtrArrayMismatchCheck
UniquePtrArrayMismatchCheck(StringRef Name, ClangTidyContext *Context)
Definition:
UniquePtrArrayMismatchCheck.cpp:15
clang::tidy::bugprone::UniquePtrArrayMismatchCheck::getSmartPointerClassMatcher
SmartPtrClassMatcher getSmartPointerClassMatcher() const override
Returns matcher that match with different smart pointer classes.
Definition:
UniquePtrArrayMismatchCheck.cpp:20
clang::ast_matchers
Definition:
AbseilMatcher.h:13
clang::tidy::bugprone
Definition:
ArgumentCommentCheck.cpp:19
Generated on Thu Nov 21 2024 14:00:57 for clang-tools by
1.9.6