clang-tools 10.0.0

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
19 class LoopConvertCheck : public ClangTidyCheck {
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
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:472
clang::tidy::modernize::UsageResult
llvm::SmallVector< Usage, 8 > UsageResult
Definition: LoopConvertUtils.h:270
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:47
clang::tidy::modernize::LoopConvertCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: LoopConvertCheck.cpp:482
clang::tidy::modernize::LoopConvertCheck
Definition: LoopConvertCheck.h:19
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:27
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:97
clang::tidy::modernize::VariableNamer::NamingStyle
NamingStyle
Definition: LoopConvertUtils.h:425
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:808
clang::tidy::modernize::LoopFixerKind
LoopFixerKind
Definition: LoopConvertUtils.h:29
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:77
clang::tidy::modernize::LoopConvertCheck::LoopConvertCheck
LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
Definition: LoopConvertCheck.cpp:457
clang::tidy::modernize::Confidence::Level
Level
Definition: LoopConvertUtils.h:244