MakeSharedCheck.cpp 1.1 KB

123456789101112131415161718192021222324252627282930
  1. //===--- MakeSharedCheck.cpp - clang-tidy----------------------------------===//
  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. #include "MakeSharedCheck.h"
  9. // FixItHint - Hint to check documentation script to mark this check as
  10. // providing a FixIt.
  11. using namespace clang::ast_matchers;
  12. namespace clang::tidy::modernize {
  13. MakeSharedCheck::MakeSharedCheck(StringRef Name, ClangTidyContext *Context)
  14. : MakeSmartPtrCheck(Name, Context, "std::make_shared") {}
  15. MakeSharedCheck::SmartPtrTypeMatcher
  16. MakeSharedCheck::getSmartPointerTypeMatcher() const {
  17. return qualType(hasUnqualifiedDesugaredType(
  18. recordType(hasDeclaration(classTemplateSpecializationDecl(
  19. hasName("::std::shared_ptr"), templateArgumentCountIs(1),
  20. hasTemplateArgument(0, templateArgument(refersToType(
  21. qualType().bind(PointerType)))))))));
  22. }
  23. } // namespace clang::tidy::modernize