clang-tools  10.0.0git
LoopConvertCheck.h
Go to the documentation of this file.
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 
20 public:
21  LoopConvertCheck(StringRef Name, ClangTidyContext *Context);
22  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
23  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
24  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
25 
26 private:
27  struct RangeDescriptor {
28  RangeDescriptor();
29  bool ContainerNeedsDereference;
30  bool DerefByConstRef;
31  bool DerefByValue;
32  std::string ContainerString;
33  QualType ElemType;
34  };
35 
36  void getAliasRange(SourceManager &SM, SourceRange &DeclRange);
37 
38  void doConversion(ASTContext *Context, const VarDecl *IndexVar,
39  const ValueDecl *MaybeContainer, const UsageResult &Usages,
40  const DeclStmt *AliasDecl, bool AliasUseRequired,
41  bool AliasFromForInit, const ForStmt *Loop,
42  RangeDescriptor Descriptor);
43 
44  StringRef getContainerString(ASTContext *Context, const ForStmt *Loop,
45  const Expr *ContainerExpr);
46 
47  void getArrayLoopQualifiers(ASTContext *Context,
48  const ast_matchers::BoundNodes &Nodes,
49  const Expr *ContainerExpr,
50  const UsageResult &Usages,
51  RangeDescriptor &Descriptor);
52 
53  void getIteratorLoopQualifiers(ASTContext *Context,
54  const ast_matchers::BoundNodes &Nodes,
55  RangeDescriptor &Descriptor);
56 
57  void determineRangeDescriptor(ASTContext *Context,
58  const ast_matchers::BoundNodes &Nodes,
59  const ForStmt *Loop, LoopFixerKind FixerKind,
60  const Expr *ContainerExpr,
61  const UsageResult &Usages,
62  RangeDescriptor &Descriptor);
63 
64  bool isConvertible(ASTContext *Context, const ast_matchers::BoundNodes &Nodes,
65  const ForStmt *Loop, LoopFixerKind FixerKind);
66 
67  std::unique_ptr<TUTrackingInfo> TUInfo;
68  const unsigned long long MaxCopySize;
69  const Confidence::Level MinConfidence;
70  const VariableNamer::NamingStyle NamingStyle;
71 };
72 
73 } // namespace modernize
74 } // namespace tidy
75 } // namespace clang
76 
77 #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
Base class for all clang-tidy checks.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
static constexpr llvm::StringLiteral Name
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.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
LoopConvertCheck(StringRef Name, ClangTidyContext *Context)