Piotr Padlewski | ce18ade | 2016-05-02 16:56:39 +0000 | [diff] [blame] | 1 | //===--- 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 | |
| 16 | namespace clang { |
| 17 | namespace tidy { |
| 18 | namespace modernize { |
| 19 | |
| 20 | /// Base class for MakeSharedCheck and MakeUniqueCheck. |
| 21 | class MakeSmartPtrCheck : public ClangTidyCheck { |
| 22 | public: |
| 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 | |
| 29 | protected: |
| 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 | |
| 42 | private: |
| 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 |