clang-tools  5.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,
20  : MakeSmartPtrCheck(Name, Context, "std::make_unique") {}
21 
24  return qualType(hasDeclaration(classTemplateSpecializationDecl(
25  hasName("::std::unique_ptr"), templateArgumentCountIs(2),
26  hasTemplateArgument(
27  0, templateArgument(refersToType(qualType().bind(PointerType)))),
28  hasTemplateArgument(
29  1,
30  templateArgument(refersToType(
31  qualType(hasDeclaration(classTemplateSpecializationDecl(
32  hasName("::std::default_delete"), templateArgumentCountIs(1),
33  hasTemplateArgument(
34  0, templateArgument(refersToType(
35  qualType(equalsBoundNode(PointerType))))))))))))));
36 }
37 
38 } // namespace modernize
39 } // namespace tidy
40 } // namespace clang
ast_matchers::internal::BindableMatcher< QualType > SmartPtrTypeMatcher
StringHandle Name
SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override
Returns matcher that match with different smart pointer types.
ClangTidyContext & Context
Definition: ClangTidy.cpp:87
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Base class for MakeSharedCheck and MakeUniqueCheck.