Alexander Kornienko | 5a520f6 | 2016-05-09 10:56:57 +0000 | [diff] [blame] | 1 | //===--- UnconventionalAssignOperatorCheck.h - clang-tidy -------*- C++ -*-===// |
Samuel Benzaquen | b5cbe01 | 2015-02-09 17:50:40 +0000 | [diff] [blame] | 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 | |
Alexander Kornienko | 6658055 | 2015-03-09 16:52:33 +0000 | [diff] [blame] | 10 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSIGNOPERATORSIGNATURECHECK_H |
| 11 | #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSIGNOPERATORSIGNATURECHECK_H |
Samuel Benzaquen | b5cbe01 | 2015-02-09 17:50:40 +0000 | [diff] [blame] | 12 | |
| 13 | #include "../ClangTidy.h" |
| 14 | |
| 15 | namespace clang { |
| 16 | namespace tidy { |
Alexander Kornienko | 2b312420 | 2015-03-02 12:25:03 +0000 | [diff] [blame] | 17 | namespace misc { |
Samuel Benzaquen | b5cbe01 | 2015-02-09 17:50:40 +0000 | [diff] [blame] | 18 | |
Gabor Horvath | 112d1e8 | 2016-05-04 12:02:22 +0000 | [diff] [blame] | 19 | /// Finds declarations of assignment operators with the wrong return and/or |
| 20 | /// argument types and definitions with good return type but wrong return |
| 21 | /// statements. |
Samuel Benzaquen | b5cbe01 | 2015-02-09 17:50:40 +0000 | [diff] [blame] | 22 | /// |
Alexander Kornienko | f8ed0a8 | 2015-08-27 18:01:58 +0000 | [diff] [blame] | 23 | /// * The return type must be `Class&`. |
| 24 | /// * Works with move-assign and assign by value. |
| 25 | /// * Private and deleted operators are ignored. |
Gabor Horvath | 112d1e8 | 2016-05-04 12:02:22 +0000 | [diff] [blame] | 26 | /// * The operator must always return ``*this``. |
| 27 | /// |
| 28 | /// For the user-facing documentation see: |
| 29 | /// http://clang.llvm.org/extra/clang-tidy/checks/misc-unconventional-assign-operator.html |
| 30 | class UnconventionalAssignOperatorCheck : public ClangTidyCheck { |
Samuel Benzaquen | b5cbe01 | 2015-02-09 17:50:40 +0000 | [diff] [blame] | 31 | public: |
Gabor Horvath | 112d1e8 | 2016-05-04 12:02:22 +0000 | [diff] [blame] | 32 | UnconventionalAssignOperatorCheck(StringRef Name, ClangTidyContext *Context) |
Samuel Benzaquen | b5cbe01 | 2015-02-09 17:50:40 +0000 | [diff] [blame] | 33 | : ClangTidyCheck(Name, Context) {} |
| 34 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; |
| 35 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 36 | }; |
| 37 | |
Alexander Kornienko | 2b312420 | 2015-03-02 12:25:03 +0000 | [diff] [blame] | 38 | } // namespace misc |
Samuel Benzaquen | b5cbe01 | 2015-02-09 17:50:40 +0000 | [diff] [blame] | 39 | } // namespace tidy |
| 40 | } // namespace clang |
| 41 | |
Alexander Kornienko | 6658055 | 2015-03-09 16:52:33 +0000 | [diff] [blame] | 42 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSIGNOPERATORSIGNATURECHECK_H |