Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
[clang-tidy] Add loop-convert check to clang-tidy.
Browse files Browse the repository at this point in the history
Move LoopConvert from clang-modernize to modernize module in clang-tidy.

http://reviews.llvm.org/D12076

Patch by Angel Garcia!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245427 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
alexfh committed Aug 19, 2015
1 parent 443f869 commit f95ab50
Show file tree
Hide file tree
Showing 10 changed files with 3,756 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang-tidy/modernize/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set(LLVM_LINK_COMPONENTS support)

add_clang_library(clangTidyModernizeModule
LoopConvertCheck.cpp
LoopConvertUtils.cpp
ModernizeTidyModule.cpp
PassByValueCheck.cpp

Expand Down
668 changes: 668 additions & 0 deletions clang-tidy/modernize/LoopConvertCheck.cpp

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions clang-tidy/modernize/LoopConvertCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//===--- 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:
void doConversion(ASTContext *Context, const VarDecl *IndexVar,
const VarDecl *MaybeContainer, StringRef ContainerString,
const UsageResult &Usages, const DeclStmt *AliasDecl,
bool AliasUseRequired, bool AliasFromForInit,
const ForStmt *TheLoop, bool ContainerNeedsDereference,
bool DerefByValue, bool DerefByConstRef);

StringRef checkRejections(ASTContext *Context, const Expr *ContainerExpr,
const ForStmt *TheLoop);

void findAndVerifyUsages(ASTContext *Context, const VarDecl *LoopVar,
const VarDecl *EndVar, const Expr *ContainerExpr,
const Expr *BoundExpr,
bool ContainerNeedsDereference, bool DerefByValue,
bool DerefByConstRef, const ForStmt *TheLoop,
LoopFixerKind FixerKind);
std::unique_ptr<TUTrackingInfo> TUInfo;
Confidence::Level MinConfidence;
};

} // namespace modernize
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_LOOP_CONVERT_H
Loading

0 comments on commit f95ab50

Please sign in to comment.