150
|
1 //===--- LoopConvertCheck.h - clang-tidy-------------------------*- C++ -*-===//
|
|
2 //
|
|
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
4 // See https://llvm.org/LICENSE.txt for license information.
|
|
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
6 //
|
|
7 //===----------------------------------------------------------------------===//
|
|
8
|
|
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
|
|
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
|
|
11
|
|
12 #include "../ClangTidyCheck.h"
|
|
13 #include "LoopConvertUtils.h"
|
|
14
|
|
15 namespace clang {
|
|
16 namespace tidy {
|
|
17 namespace modernize {
|
|
18
|
|
19 class LoopConvertCheck : public ClangTidyCheck {
|
|
20 public:
|
|
21 LoopConvertCheck(StringRef Name, ClangTidyContext *Context);
|
173
|
22 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
|
|
23 return LangOpts.CPlusPlus;
|
|
24 }
|
150
|
25 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
|
26 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
|
27 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
|
28
|
|
29 private:
|
|
30 struct RangeDescriptor {
|
|
31 RangeDescriptor();
|
|
32 bool ContainerNeedsDereference;
|
|
33 bool DerefByConstRef;
|
|
34 bool DerefByValue;
|
|
35 std::string ContainerString;
|
|
36 QualType ElemType;
|
|
37 };
|
|
38
|
|
39 void getAliasRange(SourceManager &SM, SourceRange &DeclRange);
|
|
40
|
|
41 void doConversion(ASTContext *Context, const VarDecl *IndexVar,
|
|
42 const ValueDecl *MaybeContainer, const UsageResult &Usages,
|
|
43 const DeclStmt *AliasDecl, bool AliasUseRequired,
|
|
44 bool AliasFromForInit, const ForStmt *Loop,
|
|
45 RangeDescriptor Descriptor);
|
|
46
|
|
47 StringRef getContainerString(ASTContext *Context, const ForStmt *Loop,
|
|
48 const Expr *ContainerExpr);
|
|
49
|
|
50 void getArrayLoopQualifiers(ASTContext *Context,
|
|
51 const ast_matchers::BoundNodes &Nodes,
|
|
52 const Expr *ContainerExpr,
|
|
53 const UsageResult &Usages,
|
|
54 RangeDescriptor &Descriptor);
|
|
55
|
|
56 void getIteratorLoopQualifiers(ASTContext *Context,
|
|
57 const ast_matchers::BoundNodes &Nodes,
|
|
58 RangeDescriptor &Descriptor);
|
|
59
|
|
60 void determineRangeDescriptor(ASTContext *Context,
|
|
61 const ast_matchers::BoundNodes &Nodes,
|
|
62 const ForStmt *Loop, LoopFixerKind FixerKind,
|
|
63 const Expr *ContainerExpr,
|
|
64 const UsageResult &Usages,
|
|
65 RangeDescriptor &Descriptor);
|
|
66
|
|
67 bool isConvertible(ASTContext *Context, const ast_matchers::BoundNodes &Nodes,
|
|
68 const ForStmt *Loop, LoopFixerKind FixerKind);
|
|
69
|
|
70 std::unique_ptr<TUTrackingInfo> TUInfo;
|
|
71 const unsigned long long MaxCopySize;
|
|
72 const Confidence::Level MinConfidence;
|
|
73 const VariableNamer::NamingStyle NamingStyle;
|
|
74 };
|
|
75
|
|
76 } // namespace modernize
|
|
77 } // namespace tidy
|
|
78 } // namespace clang
|
|
79
|
|
80 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
|