blob: 9de72e091d7bb574ace8b563c0f441db466455bf [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"
Eugene Zelenkoa19859d2016-05-03 01:13:27 +000014#include "clang/ASTMatchers/ASTMatchFinder.h"
15#include "clang/ASTMatchers/ASTMatchersInternal.h"
16#include "llvm/ADT/StringRef.h"
Piotr Padlewskice18ade2016-05-02 16:56:39 +000017#include <string>
18
19namespace clang {
20namespace tidy {
21namespace modernize {
22
23/// Base class for MakeSharedCheck and MakeUniqueCheck.
24class MakeSmartPtrCheck : public ClangTidyCheck {
25public:
26 MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
27 std::string makeSmartPtrFunctionName);
Eugene Zelenkoa19859d2016-05-03 01:13:27 +000028 void registerMatchers(ast_matchers::MatchFinder *Finder) final;
29 void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
Piotr Padlewskice18ade2016-05-02 16:56:39 +000030
31protected:
32 using SmartPtrTypeMatcher = ast_matchers::internal::BindableMatcher<QualType>;
33
34 /// Returns matcher that match with different smart pointer types.
35 ///
36 /// Requires to bind pointer type (qualType) with PointerType string declared
37 /// in this class.
38 virtual SmartPtrTypeMatcher getSmartPointerTypeMatcher() const = 0;
39
40 static const char PointerType[];
41 static const char ConstructorCall[];
42 static const char NewExpression[];
43
44private:
45 std::string makeSmartPtrFunctionName;
46};
47
48} // namespace modernize
49} // namespace tidy
50} // namespace clang
51
52#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_SMART_PTR_H