clang-tools 6.0.0

MakeUniqueCheck.cpp
Go to the documentation of this file.
1 //===--- MakeUniqueCheck.cpp - clang-tidy----------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "MakeUniqueCheck.h"
11
12 using namespace clang::ast_matchers;
13
14 namespace clang {
15 namespace tidy {
16 namespace modernize {
17
18 MakeUniqueCheck::MakeUniqueCheck(StringRef Name,
19 clang::tidy::ClangTidyContext *Context)
20 : MakeSmartPtrCheck(Name, Context, "std::make_unique") {}
21
22 MakeUniqueCheck::SmartPtrTypeMatcher
23 MakeUniqueCheck::getSmartPointerTypeMatcher() const {
24 return qualType(hasUnqualifiedDesugaredType(
25 recordType(hasDeclaration(classTemplateSpecializationDecl(
26 hasName("::std::unique_ptr"), templateArgumentCountIs(2),
27 hasTemplateArgument(
28 0, templateArgument(refersToType(qualType().bind(PointerType)))),
29 hasTemplateArgument(
30 1, templateArgument(refersToType(
31 qualType(hasDeclaration(classTemplateSpecializationDecl(
32 hasName("::std::default_delete"),
33 templateArgumentCountIs(1),
34 hasTemplateArgument(
35 0, templateArgument(refersToType(qualType(
36 equalsBoundNode(PointerType))))))))))))))));
37 }
38
39 } // namespace modernize
40 } // namespace tidy
41 } // namespace clang
clang::ast_matchers
Definition: ClangTidyDiagnosticConsumer.h:27
clang::tidy::modernize::MakeSmartPtrCheck::SmartPtrTypeMatcher
ast_matchers::internal::BindableMatcher< QualType > SmartPtrTypeMatcher
Definition: MakeSmartPtrCheck.h:35
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
clang::tidy::modernize::MakeUniqueCheck::getSmartPointerTypeMatcher
SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override
Returns matcher that match with different smart pointer types.
Definition: MakeUniqueCheck.cpp:23
clang::tidy::modernize::MakeSmartPtrCheck::PointerType
static const char PointerType[]
Definition: MakeSmartPtrCheck.h:43
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104
MakeUniqueCheck.h
clang::tidy::modernize::MakeSmartPtrCheck
Base class for MakeSharedCheck and MakeUniqueCheck.
Definition: MakeSmartPtrCheck.h:25