Files
clang-p2996/clang-tools-extra/loop-convert/LoopMatchers.h
Sam Panzer 4cf99cfdc7 loop-convert, a C++11 for loop modernizer
A new Clang-based tool which converts for loops to use the range-based
syntax new to C++11. Three kinds of loops can be converted:
 - Loops over statically allocated arrays
 - Loops over containers, using iterators
 - Loops over array-like containers, using operator[] and at()

Each transformation is assigned a confidence level by the tool. The
minimum require confidence level to actually apply the transformation
can be specified on the command line, but the default level should be
fine for most code.

Like other tools based on RefactoringTool, it is easiest to use this
tool with a compilation database.

llvm-svn: 162627
2012-08-24 23:46:42 +00:00

44 lines
1.6 KiB
C++

//===-- loop-convert/LoopMatchers.h - Matchers for for loops ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains declarations of the matchers for use in migrating
// C++ for loops. The matchers are responsible for checking the general shape of
// the for loop, namely the init, condition, and increment portions.
// Further analysis will be needed to confirm that the loop is in fact
// convertible in the matcher callback.
//
//===----------------------------------------------------------------------===//
#ifndef _LLVM_TOOLS_CLANG_TOOLS_EXTRA_LOOP_CONVERT_LOOP_MATCHERS_H_
#define _LLVM_TOOLS_CLANG_TOOLS_EXTRA_LOOP_CONVERT_LOOP_MATCHERS_H_
#include "clang/ASTMatchers/ASTMatchers.h"
namespace clang {
namespace loop_migrate {
// Constants used for matcher name bindings
extern const char LoopName[];
extern const char ConditionBoundName[];
extern const char ConditionVarName[];
extern const char ConditionEndVarName[];
extern const char IncrementVarName[];
extern const char InitVarName[];
extern const char EndExprName[];
extern const char EndCallName[];
extern const char EndVarName[];
ast_matchers::StatementMatcher makeArrayLoopMatcher();
ast_matchers::StatementMatcher makeIteratorLoopMatcher();
ast_matchers::StatementMatcher makePseudoArrayLoopMatcher();
} //namespace loop_migrate
} //namespace clang
#endif //_LLVM_TOOLS_CLANG_TOOLS_EXTRA_LOOP_CONVERT_LOOP_MATCHERS_H_