9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
12#include "../ClangTidyCheck.h"
13#include "../utils/IncludeInserter.h"
22 return LangOpts.CPlusPlus;
27 Preprocessor *ModuleExpanderPP)
override;
28 void check(
const ast_matchers::MatchFinder::MatchResult &Result)
override;
31 struct RangeDescriptor {
32 RangeDescriptor() =
default;
33 bool ContainerNeedsDereference =
false;
34 bool DerefByConstRef =
false;
35 bool DerefByValue =
false;
36 std::string ContainerString;
38 bool NeedsReverseCall =
false;
41 void getAliasRange(SourceManager &SM, SourceRange &DeclRange);
43 void doConversion(ASTContext *Context,
const VarDecl *IndexVar,
44 const ValueDecl *MaybeContainer,
const UsageResult &Usages,
45 const DeclStmt *AliasDecl,
bool AliasUseRequired,
46 bool AliasFromForInit,
const ForStmt *Loop,
47 RangeDescriptor Descriptor);
49 StringRef getContainerString(ASTContext *Context,
const ForStmt *Loop,
50 const Expr *ContainerExpr);
52 void getArrayLoopQualifiers(ASTContext *Context,
53 const ast_matchers::BoundNodes &Nodes,
54 const Expr *ContainerExpr,
56 RangeDescriptor &Descriptor);
58 void getIteratorLoopQualifiers(ASTContext *Context,
59 const ast_matchers::BoundNodes &Nodes,
60 RangeDescriptor &Descriptor);
62 void determineRangeDescriptor(ASTContext *Context,
63 const ast_matchers::BoundNodes &Nodes,
65 const Expr *ContainerExpr,
67 RangeDescriptor &Descriptor);
69 bool isConvertible(ASTContext *Context,
const ast_matchers::BoundNodes &Nodes,
72 StringRef getReverseFunction()
const;
73 StringRef getReverseHeader()
const;
75 std::unique_ptr<TUTrackingInfo> TUInfo;
76 const unsigned long long MaxCopySize;
80 bool UseReverseRanges;
81 const bool UseCxx20IfAvailable;
82 std::string ReverseFunction;
83 std::string ReverseHeader;
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
Override this to register PPCallbacks in the preprocessor.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Produces fixes to insert specified includes to source files, if not yet present.
llvm::SmallVector< Usage, 8 > UsageResult
llvm::StringMap< ClangTidyValue > OptionMap