brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 958b4eb Raw
89 lines · c
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOPCONVERTCHECK_H10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOPCONVERTCHECK_H11 12#include "../ClangTidyCheck.h"13#include "../utils/IncludeInserter.h"14#include "LoopConvertUtils.h"15 16namespace clang::tidy::modernize {17 18class LoopConvertCheck : public ClangTidyCheck {19public:20  LoopConvertCheck(StringRef Name, ClangTidyContext *Context);21  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {22    return LangOpts.CPlusPlus;23  }24  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;25  void registerMatchers(ast_matchers::MatchFinder *Finder) override;26  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,27                           Preprocessor *ModuleExpanderPP) override;28  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;29 30private:31  struct RangeDescriptor {32    RangeDescriptor() = default;33    bool ContainerNeedsDereference = false;34    bool DerefByConstRef = false;35    bool DerefByValue = false;36    std::string ContainerString;37    QualType ElemType;38    bool NeedsReverseCall = false;39  };40 41  void getAliasRange(SourceManager &SM, SourceRange &DeclRange);42 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);48 49  StringRef getContainerString(ASTContext *Context, const ForStmt *Loop,50                               const Expr *ContainerExpr);51 52  void getArrayLoopQualifiers(ASTContext *Context,53                              const ast_matchers::BoundNodes &Nodes,54                              const Expr *ContainerExpr,55                              const UsageResult &Usages,56                              RangeDescriptor &Descriptor);57 58  void getIteratorLoopQualifiers(ASTContext *Context,59                                 const ast_matchers::BoundNodes &Nodes,60                                 RangeDescriptor &Descriptor);61 62  void determineRangeDescriptor(ASTContext *Context,63                                const ast_matchers::BoundNodes &Nodes,64                                const ForStmt *Loop, LoopFixerKind FixerKind,65                                const Expr *ContainerExpr,66                                const UsageResult &Usages,67                                RangeDescriptor &Descriptor);68 69  bool isConvertible(ASTContext *Context, const ast_matchers::BoundNodes &Nodes,70                     const ForStmt *Loop, LoopFixerKind FixerKind);71 72  StringRef getReverseFunction() const;73  StringRef getReverseHeader() const;74 75  std::unique_ptr<TUTrackingInfo> TUInfo;76  const unsigned long long MaxCopySize;77  const Confidence::Level MinConfidence;78  const VariableNamer::NamingStyle NamingStyle;79  utils::IncludeInserter Inserter;80  bool UseReverseRanges;81  const bool UseCxx20IfAvailable;82  std::string ReverseFunction;83  std::string ReverseHeader;84};85 86} // namespace clang::tidy::modernize87 88#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOPCONVERTCHECK_H89