summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/Core/Transforms.h
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-04-04 20:19:58 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-04-04 20:19:58 +0000
commit858164883825a1f920839f2062f0d6bcdad2b0a6 (patch)
treeb5fd0720e87c570e5e5b65ed420946431e24a457 /clang-tools-extra/cpp11-migrate/Core/Transforms.h
parent037d2b252deeecfc4faef1c9472b2b13a0c5935f (diff)
downloadbcm5719-llvm-858164883825a1f920839f2062f0d6bcdad2b0a6.tar.gz
bcm5719-llvm-858164883825a1f920839f2062f0d6bcdad2b0a6.zip
lib-ified core cpp11-migrate functionality to support unit tests
Summary: Transform.* and Transforms.* moved to form a new library: libmigrateCore. #includes updated to point to new header locations. To support autoconf build, Cpp11Migrate.cpp moved to new subdirectory 'tool' which also contains build files for creating final binary. CMake and autoconf updated to build the new library and link it with cpp11-migrate and with cpp11-migrate unit tests. Dummy unit tests replaced with simple, but real, tests for Transform's public interface. TODO: Lib-ifying the transforms to further simplify build of cpp11-migrate. llvm-svn: 178785
Diffstat (limited to 'clang-tools-extra/cpp11-migrate/Core/Transforms.h')
-rw-r--r--clang-tools-extra/cpp11-migrate/Core/Transforms.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/clang-tools-extra/cpp11-migrate/Core/Transforms.h b/clang-tools-extra/cpp11-migrate/Core/Transforms.h
new file mode 100644
index 00000000000..e660ccf9207
--- /dev/null
+++ b/clang-tools-extra/cpp11-migrate/Core/Transforms.h
@@ -0,0 +1,70 @@
+//===-- cpp11-migrate/Transforms.h - class Transforms Def'n -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief This file provides the definition for class Transforms which is
+/// responsible for defining the command-line arguments exposing
+/// transformations to the user and applying requested transforms.
+///
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORMS_H
+#define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORMS_H
+
+#include "llvm/Support/CommandLine.h"
+#include <vector>
+
+// Forward declarations
+namespace llvm {
+namespace cl {
+class Option;
+} // namespace cl
+} // namespace llvm
+class Transform;
+
+typedef Transform *(*TransformCreator)();
+
+/// \brief Class encapsulating the creation of command line bool options
+/// for each transform and instantiating transforms chosen by the user.
+class Transforms {
+public:
+ typedef std::vector<Transform*> TransformVec;
+ typedef TransformVec::const_iterator const_iterator;
+
+public:
+
+ ~Transforms();
+
+ /// \brief Create command line options using LLVM's command line library.
+ ///
+ /// Be sure to call *before* parsing options.
+ void createTransformOpts();
+
+ /// \brief Instantiate all transforms that were selected on the command line.
+ ///
+ /// Call *after* parsing options.
+ void createSelectedTransforms();
+
+ /// \brief Return an iterator to the start of a container of instantiated
+ /// transforms.
+ const_iterator begin() const { return ChosenTransforms.begin(); }
+
+ /// \brief Return an iterator to the end of a container of instantiated
+ /// transforms.
+ const_iterator end() const { return ChosenTransforms.end(); }
+
+private:
+ typedef std::vector<std::pair<llvm::cl::opt<bool>*, TransformCreator> >
+ OptionVec;
+
+private:
+ TransformVec ChosenTransforms;
+ OptionVec Options;
+};
+
+#endif // LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORMS_H
OpenPOWER on IntegriCloud