blob: 77fd7465c6323ff17aaef2bcdd8e58885c4487ce [file] [log] [blame]
Edwin Vanedde168b2013-01-04 18:25:18 +00001//===-- cpp11-migrate/Transforms.h - class Transforms Def'n -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief This file provides the definition for class Transforms which is
12/// responsible for defining the command-line arguments exposing
13/// transformations to the user and applying requested transforms.
14///
15//===----------------------------------------------------------------------===//
16#ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORMS_H
17#define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORMS_H
18
19#include "llvm/Support/CommandLine.h"
20#include <vector>
21
22// Forward declarations
23namespace llvm {
24namespace cl {
25class Option;
26} // namespace cl
27} // namespace llvm
28class Transform;
29
30typedef Transform *(*TransformCreator)();
31
32/// \brief Class encapsulating the creation of command line bool options
33/// for each transform and instantiating transforms chosen by the user.
34class Transforms {
35public:
36 typedef std::vector<Transform*> TransformVec;
37 typedef TransformVec::const_iterator const_iterator;
38
39public:
40
41 ~Transforms();
42
43 /// \brief Create command line options using LLVM's command line library.
44 ///
45 /// Be sure to call *before* parsing options.
46 void createTransformOpts();
47
48 /// \brief Instantiate all transforms that were selected on the command line.
49 ///
50 /// Call *after* parsing options.
51 void createSelectedTransforms();
52
53 /// \brief Return an iterator to the start of a container of instantiated
54 /// transforms.
55 const_iterator begin() const { return ChosenTransforms.begin(); }
56
57 /// \brief Return an iterator to the end of a container of instantiated
58 /// transforms.
59 const_iterator end() const { return ChosenTransforms.end(); }
60
61private:
62 typedef std::vector<std::pair<llvm::cl::opt<bool>*, TransformCreator> >
63 OptionVec;
64
65private:
66 TransformVec ChosenTransforms;
67 OptionVec Options;
68};
69
70#endif // LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORMS_H