blob: 113c32947f8a2e2178bf300d0601f4c68650c3bb [file] [log] [blame]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001//===--- MakeUniqueCheck.h - clang-tidy--------------------------*- C++ -*-===//
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#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H
11
12#include "MakeSmartPtrCheck.h"
13
14namespace clang {
15namespace tidy {
16namespace modernize {
17
18/// Replace the pattern:
19/// \code
20/// std::unique_ptr<type>(new type(args...))
21/// \endcode
22///
23/// With the C++14 version:
24/// \code
25/// std::make_unique<type>(args...)
26/// \endcode
27class MakeUniqueCheck : public MakeSmartPtrCheck {
28public:
29 MakeUniqueCheck(StringRef Name, ClangTidyContext *Context);
30
31protected:
32 SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override;
33
34 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
35
36private:
37 const bool RequireCPlusPlus14;
38};
39
40} // namespace modernize
41} // namespace tidy
42} // namespace clang
43
44#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H