MakeUniqueCheck.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //===--- 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. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H
  10. #include "MakeSmartPtrCheck.h"
  11. namespace clang::tidy::modernize {
  12. /// Replace the pattern:
  13. /// \code
  14. /// std::unique_ptr<type>(new type(args...))
  15. /// \endcode
  16. ///
  17. /// With the C++14 version:
  18. /// \code
  19. /// std::make_unique<type>(args...)
  20. /// \endcode
  21. class MakeUniqueCheck : public MakeSmartPtrCheck {
  22. public:
  23. MakeUniqueCheck(StringRef Name, ClangTidyContext *Context);
  24. protected:
  25. SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override;
  26. bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
  27. private:
  28. const bool RequireCPlusPlus14;
  29. };
  30. } // namespace clang::tidy::modernize
  31. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H