clang-tools  8.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  RequireCPlusPlus14(Options.get("MakeSmartPtrFunction", "").empty()) {}
22 
25  return qualType(hasUnqualifiedDesugaredType(
26  recordType(hasDeclaration(classTemplateSpecializationDecl(
27  hasName("::std::unique_ptr"), templateArgumentCountIs(2),
28  hasTemplateArgument(
29  0, templateArgument(refersToType(qualType().bind(PointerType)))),
30  hasTemplateArgument(
31  1, templateArgument(refersToType(
32  qualType(hasDeclaration(classTemplateSpecializationDecl(
33  hasName("::std::default_delete"),
34  templateArgumentCountIs(1),
35  hasTemplateArgument(
36  0, templateArgument(refersToType(qualType(
37  equalsBoundNode(PointerType))))))))))))))));
38 }
39 
41  const LangOptions &LangOpts) const {
42  return RequireCPlusPlus14 ? LangOpts.CPlusPlus14 : LangOpts.CPlusPlus11;
43 }
44 
45 } // namespace modernize
46 } // namespace tidy
47 } // namespace clang
ast_matchers::internal::BindableMatcher< QualType > SmartPtrTypeMatcher
SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override
Returns matcher that match with different smart pointer types.
static constexpr llvm::StringLiteral Name
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Returns whether the C++ version is compatible with current check.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Base class for MakeSharedCheck and MakeUniqueCheck.