clang-tools 6.0.0

MakeSharedCheck.cpp
Go to the documentation of this file.
1 //===--- MakeSharedCheck.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 "MakeSharedCheck.h"
11
12 using namespace clang::ast_matchers;
13
14 namespace clang {
15 namespace tidy {
16 namespace modernize {
17
18 MakeSharedCheck::MakeSharedCheck(StringRef Name, ClangTidyContext *Context)
19 : MakeSmartPtrCheck(Name, Context, "std::make_shared") {}
20
21 MakeSharedCheck::SmartPtrTypeMatcher
22 MakeSharedCheck::getSmartPointerTypeMatcher() const {
23 return qualType(hasUnqualifiedDesugaredType(
24 recordType(hasDeclaration(classTemplateSpecializationDecl(
25 hasName("::std::shared_ptr"), templateArgumentCountIs(1),
26 hasTemplateArgument(0, templateArgument(refersToType(
27 qualType().bind(PointerType)))))))));
28 }
29
30 } // namespace modernize
31 } // namespace tidy
32 } // namespace clang
clang::ast_matchers
Definition: ClangTidyDiagnosticConsumer.h:27
clang::tidy::modernize::MakeSharedCheck::getSmartPointerTypeMatcher
SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override
Returns matcher that match with different smart pointer types.
Definition: MakeSharedCheck.cpp:22
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::MakeSmartPtrCheck::PointerType
static const char PointerType[]
Definition: MakeSmartPtrCheck.h:43
MakeSharedCheck.h
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104
clang::tidy::modernize::MakeSmartPtrCheck
Base class for MakeSharedCheck and MakeUniqueCheck.
Definition: MakeSmartPtrCheck.h:25