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 { |
Angel Garcia Gomez | f41a631 | 2015-09-21 09:32:59 +0000 | [diff] [blame] | 29 | RangeDescriptor(); |
Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 30 | bool ContainerNeedsDereference; |
Angel Garcia Gomez | bb9ca54 | 2015-09-11 10:02:07 +0000 | [diff] [blame] | 31 | bool DerefByConstRef; |
Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 32 | bool DerefByValue; |
Angel Garcia Gomez | f41a631 | 2015-09-21 09:32:59 +0000 | [diff] [blame] | 33 | std::string ContainerString; |
Angel Garcia Gomez | d8336f3 | 2015-10-22 13:23:46 +0000 | [diff] [blame] | 34 | QualType ElemType; |
Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
Angel Garcia Gomez | 90bf895 | 2015-10-01 13:08:21 +0000 | [diff] [blame] | 37 | void getAliasRange(SourceManager &SM, SourceRange &DeclRange); |
| 38 | |
Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 39 | void doConversion(ASTContext *Context, const VarDecl *IndexVar, |
Angel Garcia Gomez | 432ff5e | 2015-11-03 16:38:31 +0000 | [diff] [blame] | 40 | const ValueDecl *MaybeContainer, const UsageResult &Usages, |
Angel Garcia Gomez | f41a631 | 2015-09-21 09:32:59 +0000 | [diff] [blame] | 41 | const DeclStmt *AliasDecl, bool AliasUseRequired, |
| 42 | bool AliasFromForInit, const ForStmt *Loop, |
| 43 | RangeDescriptor Descriptor); |
Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 44 | |
Angel Garcia Gomez | f41a631 | 2015-09-21 09:32:59 +0000 | [diff] [blame] | 45 | StringRef getContainerString(ASTContext *Context, const ForStmt *Loop, |
| 46 | const Expr *ContainerExpr); |
Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 47 | |
Angel Garcia Gomez | f41a631 | 2015-09-21 09:32:59 +0000 | [diff] [blame] | 48 | void getArrayLoopQualifiers(ASTContext *Context, |
| 49 | const ast_matchers::BoundNodes &Nodes, |
| 50 | const Expr *ContainerExpr, |
| 51 | const UsageResult &Usages, |
| 52 | RangeDescriptor &Descriptor); |
| 53 | |
| 54 | void getIteratorLoopQualifiers(ASTContext *Context, |
| 55 | const ast_matchers::BoundNodes &Nodes, |
| 56 | RangeDescriptor &Descriptor); |
| 57 | |
| 58 | void determineRangeDescriptor(ASTContext *Context, |
| 59 | const ast_matchers::BoundNodes &Nodes, |
| 60 | const ForStmt *Loop, LoopFixerKind FixerKind, |
| 61 | const Expr *ContainerExpr, |
| 62 | const UsageResult &Usages, |
| 63 | RangeDescriptor &Descriptor); |
| 64 | |
| 65 | bool isConvertible(ASTContext *Context, const ast_matchers::BoundNodes &Nodes, |
| 66 | const ForStmt *Loop, LoopFixerKind FixerKind); |
Angel Garcia Gomez | d930ef7 | 2015-09-08 09:01:21 +0000 | [diff] [blame] | 67 | |
Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 68 | std::unique_ptr<TUTrackingInfo> TUInfo; |
Angel Garcia Gomez | 68175a0 | 2015-10-30 09:37:57 +0000 | [diff] [blame] | 69 | const unsigned long long MaxCopySize; |
Angel Garcia Gomez | 8535c6c | 2015-09-24 17:02:19 +0000 | [diff] [blame] | 70 | const Confidence::Level MinConfidence; |
| 71 | const VariableNamer::NamingStyle NamingStyle; |
Alexander Kornienko | 0497084 | 2015-08-19 09:11:46 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | } // namespace modernize |
| 75 | } // namespace tidy |
| 76 | } // namespace clang |
| 77 | |
| 78 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H |