blob: 38a8b18e04b74863b298ff053d5046b138e7db60 [file] [log] [blame]
Piotr Padlewskice18ade2016-05-02 16:56:39 +00001//===--- MakeSmartPtrCheck.h - clang-tidy------------------------*- C++ -*-===//
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#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_SMART_PTR_H
11#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_SMART_PTR_H
12
13#include "../ClangTidy.h"
14#include <string>
15
16namespace clang {
17namespace tidy {
18namespace modernize {
19
20/// Base class for MakeSharedCheck and MakeUniqueCheck.
21class MakeSmartPtrCheck : public ClangTidyCheck {
22public:
23 MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
24 std::string makeSmartPtrFunctionName);
25 void registerMatchers(ast_matchers::MatchFinder *Finder) override final;
26 void
27 check(const ast_matchers::MatchFinder::MatchResult &Result) override final;
28
29protected:
30 using SmartPtrTypeMatcher = ast_matchers::internal::BindableMatcher<QualType>;
31
32 /// Returns matcher that match with different smart pointer types.
33 ///
34 /// Requires to bind pointer type (qualType) with PointerType string declared
35 /// in this class.
36 virtual SmartPtrTypeMatcher getSmartPointerTypeMatcher() const = 0;
37
38 static const char PointerType[];
39 static const char ConstructorCall[];
40 static const char NewExpression[];
41
42private:
43 std::string makeSmartPtrFunctionName;
44};
45
46} // namespace modernize
47} // namespace tidy
48} // namespace clang
49
50#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_SMART_PTR_H