2015-08-19 17:11:46 +08:00
|
|
|
//===--- LoopConvertCheck.h - clang-tidy-------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
|
|
|
|
|
|
|
|
#include "../ClangTidy.h"
|
|
|
|
#include "LoopConvertUtils.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
|
|
|
namespace modernize {
|
|
|
|
|
|
|
|
class LoopConvertCheck : public ClangTidyCheck {
|
|
|
|
public:
|
|
|
|
LoopConvertCheck(StringRef Name, ClangTidyContext *Context);
|
|
|
|
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
|
|
|
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
|
|
|
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
|
|
|
|
|
|
|
private:
|
2015-09-08 17:01:21 +08:00
|
|
|
struct RangeDescriptor {
|
2015-09-21 17:32:59 +08:00
|
|
|
RangeDescriptor();
|
2015-09-08 17:01:21 +08:00
|
|
|
bool ContainerNeedsDereference;
|
2015-09-11 18:02:07 +08:00
|
|
|
bool DerefByConstRef;
|
2015-09-08 17:01:21 +08:00
|
|
|
bool DerefByValue;
|
2015-09-21 17:32:59 +08:00
|
|
|
std::string ContainerString;
|
2015-10-22 21:23:46 +08:00
|
|
|
QualType ElemType;
|
2015-09-08 17:01:21 +08:00
|
|
|
};
|
|
|
|
|
2015-10-01 21:08:21 +08:00
|
|
|
void getAliasRange(SourceManager &SM, SourceRange &DeclRange);
|
|
|
|
|
2015-08-19 17:11:46 +08:00
|
|
|
void doConversion(ASTContext *Context, const VarDecl *IndexVar,
|
2015-11-04 00:38:31 +08:00
|
|
|
const ValueDecl *MaybeContainer, const UsageResult &Usages,
|
2015-09-21 17:32:59 +08:00
|
|
|
const DeclStmt *AliasDecl, bool AliasUseRequired,
|
|
|
|
bool AliasFromForInit, const ForStmt *Loop,
|
|
|
|
RangeDescriptor Descriptor);
|
|
|
|
|
|
|
|
StringRef getContainerString(ASTContext *Context, const ForStmt *Loop,
|
|
|
|
const Expr *ContainerExpr);
|
|
|
|
|
|
|
|
void getArrayLoopQualifiers(ASTContext *Context,
|
|
|
|
const ast_matchers::BoundNodes &Nodes,
|
|
|
|
const Expr *ContainerExpr,
|
|
|
|
const UsageResult &Usages,
|
|
|
|
RangeDescriptor &Descriptor);
|
|
|
|
|
|
|
|
void getIteratorLoopQualifiers(ASTContext *Context,
|
|
|
|
const ast_matchers::BoundNodes &Nodes,
|
|
|
|
RangeDescriptor &Descriptor);
|
|
|
|
|
|
|
|
void determineRangeDescriptor(ASTContext *Context,
|
|
|
|
const ast_matchers::BoundNodes &Nodes,
|
|
|
|
const ForStmt *Loop, LoopFixerKind FixerKind,
|
|
|
|
const Expr *ContainerExpr,
|
|
|
|
const UsageResult &Usages,
|
|
|
|
RangeDescriptor &Descriptor);
|
|
|
|
|
|
|
|
bool isConvertible(ASTContext *Context, const ast_matchers::BoundNodes &Nodes,
|
|
|
|
const ForStmt *Loop, LoopFixerKind FixerKind);
|
2015-09-08 17:01:21 +08:00
|
|
|
|
2015-08-19 17:11:46 +08:00
|
|
|
std::unique_ptr<TUTrackingInfo> TUInfo;
|
2015-10-30 17:37:57 +08:00
|
|
|
const unsigned long long MaxCopySize;
|
2015-09-25 01:02:19 +08:00
|
|
|
const Confidence::Level MinConfidence;
|
|
|
|
const VariableNamer::NamingStyle NamingStyle;
|
2015-08-19 17:11:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace modernize
|
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
|