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,
20  : MakeSmartPtrCheck(Name, Context, "std::make_unique") {}
21 
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
ast_matchers::internal::BindableMatcher< QualType > SmartPtrTypeMatcher
StringHandle Name
SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override
Returns matcher that match with different smart pointer types.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Base class for MakeSharedCheck and MakeUniqueCheck.