clang-tools 10.0.0

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