clang-tools  5.0.0
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 
21 public:
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
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
llvm::SmallVector< Usage, 8 > UsageResult
StringHandle Name
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:275
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
SourceManager & SM
std::map< std::string, std::string > OptionMap
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
ClangTidyContext & Context
Definition: ClangTidy.cpp:87
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
LoopConvertCheck(StringRef Name, ClangTidyContext *Context)