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" |
Eugene Zelenko | a19859d | 2016-05-03 01:13:27 +0000 | [diff] [blame^] | 14 | #include "clang/ASTMatchers/ASTMatchFinder.h" |
| 15 | #include "clang/ASTMatchers/ASTMatchersInternal.h" |
| 16 | #include "llvm/ADT/StringRef.h" |
Piotr Padlewski | ce18ade | 2016-05-02 16:56:39 +0000 | [diff] [blame] | 17 | #include <string> |
| 18 | |
| 19 | namespace clang { |
| 20 | namespace tidy { |
| 21 | namespace modernize { |
| 22 | |
| 23 | /// Base class for MakeSharedCheck and MakeUniqueCheck. |
| 24 | class MakeSmartPtrCheck : public ClangTidyCheck { |
| 25 | public: |
| 26 | MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context, |
| 27 | std::string makeSmartPtrFunctionName); |
Eugene Zelenko | a19859d | 2016-05-03 01:13:27 +0000 | [diff] [blame^] | 28 | void registerMatchers(ast_matchers::MatchFinder *Finder) final; |
| 29 | void check(const ast_matchers::MatchFinder::MatchResult &Result) final; |
Piotr Padlewski | ce18ade | 2016-05-02 16:56:39 +0000 | [diff] [blame] | 30 | |
| 31 | protected: |
| 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 | |
| 44 | private: |
| 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 |