clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

LoopConvertCheck.h
Go to the documentation of this file.
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:
28 struct RangeDescriptor {
29 RangeDescriptor();
30 bool ContainerNeedsDereference;
31 bool DerefByConstRef;
32 bool DerefByValue;
33 std::string ContainerString;
34 QualType ElemType;
35 };
36
37 void getAliasRange(SourceManager &SM, SourceRange &DeclRange);
38
39 void doConversion(ASTContext *Context, const VarDecl *IndexVar,
40 const ValueDecl *MaybeContainer, const UsageResult &Usages,
41 const DeclStmt *AliasDecl, bool AliasUseRequired,
42 bool AliasFromForInit, const ForStmt *Loop,
43 RangeDescriptor Descriptor);
44
45 StringRef getContainerString(ASTContext *Context, const ForStmt *Loop,
46 const Expr *ContainerExpr);
47
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);
67
68 std::unique_ptr<TUTrackingInfo> TUInfo;
69 const unsigned long long MaxCopySize;
70 const Confidence::Level MinConfidence;
71 const VariableNamer::NamingStyle NamingStyle;
72 };
73
74 } // namespace modernize
75 } // namespace tidy
76 } // namespace clang
77
78 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
clang::tidy::modernize::LoopConvertCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition: LoopConvertCheck.cpp:456
clang::tidy::modernize::UsageResult
llvm::SmallVector< Usage, 8 > UsageResult
Definition: LoopConvertUtils.h:264
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
Finder
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:188
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:102
clang::tidy::modernize::LoopConvertCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register ASTMatchers with Finder.
Definition: LoopConvertCheck.cpp:466
SM
SourceManager & SM
Definition: IncludeOrderCheck.cpp:44
clang::tidy::modernize::LoopConvertCheck
Definition: LoopConvertCheck.h:20
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:82
clang::tidy::modernize::VariableNamer::NamingStyle
NamingStyle
Definition: LoopConvertUtils.h:418
LoopConvertUtils.h
clang::tidy::modernize::LoopConvertCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: LoopConvertCheck.cpp:787
clang::tidy::modernize::LoopFixerKind
LoopFixerKind
Definition: LoopConvertUtils.h:23
Context
ClangTidyContext & Context
Definition: ClangTidy.cpp:93
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:124
clang::tidy::modernize::LoopConvertCheck::LoopConvertCheck
LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
Definition: LoopConvertCheck.cpp:441
clang::tidy::modernize::Confidence::Level
Level
Definition: LoopConvertUtils.h:238
Result
const NamedDecl * Result
Definition: USRFinder.cpp:121