| Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 1 | //===--- LoopConvertCheck.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_LOOP_CONVERT_H |
| 11 | #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H |
| 12 | |
| 13 | #include "../ClangTidy.h" |
| 14 | #include "LoopConvertUtils.h" |
| 15 | |
| 16 | namespace clang { |
| 17 | namespace tidy { |
| 18 | namespace modernize { |
| 19 | |
| 20 | class LoopConvertCheck : public ClangTidyCheck { |
| 21 | public: |
| 22 | LoopConvertCheck(StringRef Name, ClangTidyContext *Context); |
| 23 | void storeOptions(ClangTidyOptions::OptionMap &Opts) override; |
| 24 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; |
| 25 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 26 | |
| 27 | private: |
| Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 28 | struct RangeDescriptor { |
| 29 | bool ContainerNeedsDereference; |
| Angel Garcia Gomez | bb9ca54 | 2015-09-11 10:02:07 +0000 | [diff] [blame] | 30 | bool DerefByConstRef; |
| Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 31 | bool DerefByValue; |
| 32 | bool IsTriviallyCopyable; |
| Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 35 | void doConversion(ASTContext *Context, const VarDecl *IndexVar, |
| 36 | const VarDecl *MaybeContainer, StringRef ContainerString, |
| 37 | const UsageResult &Usages, const DeclStmt *AliasDecl, |
| 38 | bool AliasUseRequired, bool AliasFromForInit, |
| Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 39 | const ForStmt *TheLoop, RangeDescriptor Descriptor); |
| Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 40 | |
| 41 | StringRef checkRejections(ASTContext *Context, const Expr *ContainerExpr, |
| 42 | const ForStmt *TheLoop); |
| 43 | |
| 44 | void findAndVerifyUsages(ASTContext *Context, const VarDecl *LoopVar, |
| 45 | const VarDecl *EndVar, const Expr *ContainerExpr, |
| Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 46 | const Expr *BoundExpr, const ForStmt *TheLoop, |
| 47 | LoopFixerKind FixerKind, RangeDescriptor Descriptor); |
| 48 | |
| Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 49 | std::unique_ptr<TUTrackingInfo> TUInfo; |
| 50 | Confidence::Level MinConfidence; |
| 51 | }; |
| 52 | |
| 53 | } // namespace modernize |
| 54 | } // namespace tidy |
| 55 | } // namespace clang |
| 56 | |
| 57 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H |