Hi tareqsiraj, arielbernal,

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.

http://llvm-reviews.chandlerc.com/D623

Files:
  Makefile
  cpp11-migrate/CMakeLists.txt
  cpp11-migrate/Core/CMakeLists.txt
  cpp11-migrate/Core/Makefile
  cpp11-migrate/Core/Transform.cpp
  cpp11-migrate/Transform.cpp
  cpp11-migrate/Core/Transform.h
  cpp11-migrate/Transform.h
  cpp11-migrate/Core/Transforms.cpp
  cpp11-migrate/Transforms.cpp
  cpp11-migrate/Core/Transforms.h
  cpp11-migrate/Transforms.h
  cpp11-migrate/LoopConvert/LoopActions.h
  cpp11-migrate/LoopConvert/LoopConvert.h
  cpp11-migrate/Makefile
  cpp11-migrate/UseAuto/UseAuto.h
  cpp11-migrate/UseAuto/UseAutoActions.h
  cpp11-migrate/UseNullptr/NullptrActions.h
  cpp11-migrate/UseNullptr/UseNullptr.h
  cpp11-migrate/tool/CMakeLists.txt
  cpp11-migrate/tool/Cpp11Migrate.cpp
  cpp11-migrate/Cpp11Migrate.cpp
  cpp11-migrate/tool/Makefile
  unittests/cpp11-migrate/CMakeLists.txt
  unittests/cpp11-migrate/Makefile
  unittests/cpp11-migrate/TransformTest.cpp
  unittests/cpp11-migrate/dummy.cpp
Index: Makefile
===================================================================
--- Makefile
+++ Makefile
@@ -11,7 +11,8 @@
 
 include $(CLANG_LEVEL)/../../Makefile.config
 
-PARALLEL_DIRS := remove-cstr-calls tool-template cpp11-migrate modularize unittests
+PARALLEL_DIRS := remove-cstr-calls tool-template modularize
+DIRS := cpp11-migrate unittests
 
 include $(CLANG_LEVEL)/Makefile
 
Index: cpp11-migrate/CMakeLists.txt
===================================================================
--- cpp11-migrate/CMakeLists.txt
+++ cpp11-migrate/CMakeLists.txt
@@ -2,32 +2,5 @@
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 
-set (Cpp11MigrateSources
-  Cpp11Migrate.cpp
-  Transforms.cpp
-  Transform.cpp
-  )
-
-# For each transform subdirectory.
-file(GLOB_RECURSE LoopConvertSources "LoopConvert/*.cpp")
-list(APPEND Cpp11MigrateSources ${LoopConvertSources})
-
-file(GLOB_RECURSE UseNullptrSources "UseNullptr/*.cpp")
-list(APPEND Cpp11MigrateSources ${UseNullptrSources})
-
-file(GLOB_RECURSE UseAutoSources "UseAuto/*.cpp")
-list(APPEND Cpp11MigrateSources ${UseAutoSources})
-
-add_clang_executable(cpp11-migrate
-  ${Cpp11MigrateSources}
-  )
-
-add_dependencies(cpp11-migrate
-  clang-headers
-  )
-
-target_link_libraries(cpp11-migrate
-  clangTooling
-  clangBasic
-  clangASTMatchers
-  )
+add_subdirectory(tool)
+add_subdirectory(Core)
Index: cpp11-migrate/Core/CMakeLists.txt
===================================================================
--- /dev/null
+++ cpp11-migrate/Core/CMakeLists.txt
@@ -0,0 +1,11 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(migrateCore
+  Transforms.cpp
+  Transform.cpp
+  )
+target_link_libraries(migrateCore
+  clangTooling
+  clangBasic
+  clangASTMatchers
+  )
Index: cpp11-migrate/Core/Makefile
===================================================================
--- /dev/null
+++ cpp11-migrate/Core/Makefile
@@ -0,0 +1,14 @@
+##===- cpp11-migrate/Core/Makefile -------------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+CLANG_LEVEL := ../../../..
+LIBRARYNAME := migrateCore
+
+include $(CLANG_LEVEL)/Makefile
+
+CPP.Flags += -I$(PROJ_SRC_DIR)/..
Index: cpp11-migrate/Core/Transform.cpp
===================================================================
--- cpp11-migrate/Core/Transform.cpp
+++ cpp11-migrate/Core/Transform.cpp
@@ -1,4 +1,4 @@
-#include "Transform.h"
+#include "Core/Transform.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Rewrite/Core/Rewriter.h"
Index: cpp11-migrate/Transform.h
===================================================================
--- /dev/null
+++ cpp11-migrate/Transform.h
@@ -1,177 +0,0 @@
-//===-- cpp11-migrate/Transform.h - Transform Base Class 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 the base Transform class from
-/// which all transforms must subclass.
-///
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORM_H
-#define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORM_H
-
-#include <string>
-#include <vector>
-
-// For RewriterContainer
-#include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Basic/SourceManager.h"
-#include "llvm/Support/raw_ostream.h"
-////
-
-
-/// \brief Description of the riskiness of actions that can be taken by
-/// transforms.
-enum RiskLevel {
-  /// Transformations that will not change semantics.
-  RL_Safe,
-
-  /// Transformations that might change semantics.
-  RL_Reasonable,
-
-  /// Transformations that are likely to change semantics.
-  RL_Risky
-};
-
-// Forward declarations
-namespace clang {
-namespace tooling {
-class CompilationDatabase;
-} // namespace tooling
-} // namespace clang
-
-/// \brief The key is the path of a file, which is mapped to a
-/// buffer with the possibly modified contents of that file.
-typedef std::map<std::string, std::string> FileContentsByPath;
-
-/// \brief In \p Results place copies of the buffers resulting from applying
-/// all rewrites represented by \p Rewrite.
-///
-/// \p Results is made up of pairs {filename, buffer contents}. Pairs are
-/// simply appended to \p Results.
-void collectResults(clang::Rewriter &Rewrite,
-                    const FileContentsByPath &InputStates,
-                    FileContentsByPath &Results);
-
-/// \brief Class for containing a Rewriter instance and all of
-/// its lifetime dependencies.
-///
-/// Subclasses of Transform using RefactoringTools will need to create
-/// Rewriters in order to apply Replacements and get the resulting buffer.
-/// Rewriter requires some objects to exist at least as long as it does so this
-/// class contains instances of those objects.
-///
-/// FIXME: These objects should really come from somewhere more global instead
-/// of being recreated for every Transform subclass, especially diagnostics.
-class RewriterContainer {
-public:
-  RewriterContainer(clang::FileManager &Files,
-                    const FileContentsByPath &InputStates)
-    : DiagOpts(new clang::DiagnosticOptions()),
-      DiagnosticPrinter(llvm::errs(), DiagOpts.getPtr()),
-      Diagnostics(llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs>(
-                    new clang::DiagnosticIDs()),
-                  DiagOpts.getPtr(), &DiagnosticPrinter, false),
-      Sources(Diagnostics, Files),
-      Rewrite(Sources, DefaultLangOptions) {
-
-    // Overwrite source manager's file contents with data from InputStates
-    for (FileContentsByPath::const_iterator I = InputStates.begin(),
-                                            E = InputStates.end();
-         I != E; ++I) {
-      Sources.overrideFileContents(Files.getFile(I->first),
-                                   llvm::MemoryBuffer::getMemBuffer(I->second));
-    }
-  }
-
-  clang::Rewriter &getRewriter() { return Rewrite; }
-
-private:
-  clang::LangOptions DefaultLangOptions;
-  llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> DiagOpts;
-  clang::TextDiagnosticPrinter DiagnosticPrinter;
-  clang::DiagnosticsEngine Diagnostics;
-  clang::SourceManager Sources;
-  clang::Rewriter Rewrite;
-};
-
-/// \brief Abstract base class for all C++11 migration transforms.
-class Transform {
-public:
-  Transform(llvm::StringRef Name) : Name(Name) {
-    Reset();
-  }
-
-  virtual ~Transform() {}
-
-  /// \brief Apply a transform to all files listed in \p SourcePaths.
-  ///
-  /// \p Database must contain information for how to compile all files in \p
-  /// SourcePaths. \p InputStates contains the file contents of files in \p
-  /// SourcePaths and should take precedence over content of files on disk.
-  /// Upon return, \p ResultStates shall contain the result of performing this
-  /// transform on the files listed in \p SourcePaths.
-  virtual int apply(const FileContentsByPath &InputStates,
-                    RiskLevel MaxRiskLevel,
-                    const clang::tooling::CompilationDatabase &Database,
-                    const std::vector<std::string> &SourcePaths,
-                    FileContentsByPath &ResultStates) = 0;
-
-  /// \brief Query if changes were made during the last call to apply().
-  bool getChangesMade() const { return AcceptedChanges > 0; }
-
-  /// \brief Query if changes were not made due to conflicts with other changes
-  /// made during the last call to apply() or if changes were too risky for the
-  /// requested risk level.
-  bool getChangesNotMade() const {
-    return RejectedChanges > 0 || DeferredChanges > 0;
-  }
-
-  /// \brief Query the number of accepted changes.
-  unsigned getAcceptedChanges() const { return AcceptedChanges; }
-  /// \brief Query the number of changes considered too risky.
-  unsigned getRejectedChanges() const { return RejectedChanges; }
-  /// \brief Query the number of changes not made because they conflicted with
-  /// early changes.
-  unsigned getDeferredChanges() const { return DeferredChanges; }
-
-  /// \brief Query transform name.
-  llvm::StringRef getName() const { return Name; }
-
-  /// \brief Reset internal state of the transform.
-  ///
-  /// Useful if calling apply() several times with one instantiation of a
-  /// transform.
-  void Reset() {
-    AcceptedChanges = 0;
-    RejectedChanges = 0;
-    DeferredChanges = 0;
-  }
-
-protected:
-  void setAcceptedChanges(unsigned Changes) {
-    AcceptedChanges = Changes;
-  }
-  void setRejectedChanges(unsigned Changes) {
-    RejectedChanges = Changes;
-  }
-  void setDeferredChanges(unsigned Changes) {
-    DeferredChanges = Changes;
-  }
-
-private:
-  const std::string Name;
-  unsigned AcceptedChanges;
-  unsigned RejectedChanges;
-  unsigned DeferredChanges;
-};
-
-#endif // LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORM_H
Index: cpp11-migrate/Core/Transforms.cpp
===================================================================
--- cpp11-migrate/Core/Transforms.cpp
+++ cpp11-migrate/Core/Transforms.cpp
@@ -12,7 +12,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Transforms.h"
+#include "Core/Transforms.h"
 #include "LoopConvert/LoopConvert.h"
 #include "UseNullptr/UseNullptr.h"
 #include "UseAuto/UseAuto.h"
Index: cpp11-migrate/Transforms.h
===================================================================
--- /dev/null
+++ cpp11-migrate/Transforms.h
@@ -1,70 +0,0 @@
-//===-- 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
Index: cpp11-migrate/LoopConvert/LoopActions.h
===================================================================
--- cpp11-migrate/LoopConvert/LoopActions.h
+++ cpp11-migrate/LoopConvert/LoopActions.h
@@ -16,7 +16,7 @@
 #define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_LOOP_ACTIONS_H
 
 #include "StmtAncestor.h"
-#include "Transform.h"
+#include "Core/Transform.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
Index: cpp11-migrate/LoopConvert/LoopConvert.h
===================================================================
--- cpp11-migrate/LoopConvert/LoopConvert.h
+++ cpp11-migrate/LoopConvert/LoopConvert.h
@@ -16,7 +16,7 @@
 #ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_LOOP_CONVERT_H
 #define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_LOOP_CONVERT_H
 
-#include "Transform.h"
+#include "Core/Transform.h"
 #include "llvm/Support/Compiler.h" // For LLVM_OVERRIDE
 
 /// \brief Subclass of Transform that transforms for-loops into range-based
Index: cpp11-migrate/Makefile
===================================================================
--- cpp11-migrate/Makefile
+++ cpp11-migrate/Makefile
@@ -8,42 +8,8 @@
 ##===----------------------------------------------------------------------===##
 
 CLANG_LEVEL := ../../..
-
-TOOLNAME = cpp11-migrate
-NO_INSTALL = 1
-
-# No plugins, optimize startup time.
-TOOL_NO_EXPORTS = 1
-
 include $(CLANG_LEVEL)/../../Makefile.config
 
-SOURCES = Cpp11Migrate.cpp Transforms.cpp Transform.cpp
-
-# For each Transform subdirectory add to SOURCES and BUILT_SOURCES.
-# BUILT_SOURCES ensures a subdirectory is created to house object files from
-# transform subdirectories. See below for more on .objdir.
-SOURCES += $(addprefix LoopConvert/,$(notdir $(wildcard $(PROJ_SRC_DIR)/LoopConvert/*.cpp)))
-BUILT_SOURCES = $(ObjDir)/LoopConvert/.objdir
-SOURCES += $(addprefix UseNullptr/,$(notdir $(wildcard $(PROJ_SRC_DIR)/UseNullptr/*.cpp)))
-BUILT_SOURCES += $(ObjDir)/UseNullptr/.objdir
-SOURCES += $(addprefix UseAuto/,$(notdir $(wildcard $(PROJ_SRC_DIR)/UseAuto/*.cpp)))
-BUILT_SOURCES += $(ObjDir)/UseAuto/.objdir
-
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
-USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
-		   clangRewriteFrontend.a clangRewriteCore.a clangParse.a \
-		   clangSema.a clangAnalysis.a \
-		   clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a
+DIRS = Core tool
 
 include $(CLANG_LEVEL)/Makefile
-
-# BUILT_SOURCES gets used as a prereq for many top-level targets. However, at
-# the point those targets are defined, $(ObjDir) hasn't been defined and so the
-# directory to create becomes /<name>/ which is not what we want. So instead,
-# this .objdir recipe is defined at at point where $(ObjDir) is defined and
-# it's specialized to $(ObjDir) to ensure it only works on targets we want it
-# to.
-$(ObjDir)/%.objdir:
-	$(Verb) $(MKDIR) $(ObjDir)/$* > /dev/null
-	$(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
-
Index: cpp11-migrate/UseAuto/UseAuto.h
===================================================================
--- cpp11-migrate/UseAuto/UseAuto.h
+++ cpp11-migrate/UseAuto/UseAuto.h
@@ -17,7 +17,7 @@
 #ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_AUTO_H
 #define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_AUTO_H
 
-#include "Transform.h"
+#include "Core/Transform.h"
 #include "llvm/Support/Compiler.h"
 
 /// \brief Subclass of Transform that transforms type specifiers for variable
Index: cpp11-migrate/UseAuto/UseAutoActions.h
===================================================================
--- cpp11-migrate/UseAuto/UseAutoActions.h
+++ cpp11-migrate/UseAuto/UseAutoActions.h
@@ -15,7 +15,7 @@
 #ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_AUTO_ACTIONS_H
 #define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_AUTO_ACTIONS_H
 
-#include "Transform.h"
+#include "Core/Transform.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Tooling/Refactoring.h"
 
Index: cpp11-migrate/UseNullptr/NullptrActions.h
===================================================================
--- cpp11-migrate/UseNullptr/NullptrActions.h
+++ cpp11-migrate/UseNullptr/NullptrActions.h
@@ -15,7 +15,7 @@
 #ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_NULLPTR_ACTIONS_H
 #define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_NULLPTR_ACTIONS_H
 
-#include "Transform.h"
+#include "Core/Transform.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Tooling/Refactoring.h"
 
Index: cpp11-migrate/UseNullptr/UseNullptr.h
===================================================================
--- cpp11-migrate/UseNullptr/UseNullptr.h
+++ cpp11-migrate/UseNullptr/UseNullptr.h
@@ -16,7 +16,7 @@
 #ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_NULLPTR_H
 #define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_NULLPTR_H
 
-#include "Transform.h"
+#include "Core/Transform.h"
 #include "llvm/Support/Compiler.h" // For LLVM_OVERRIDE
 
 /// \brief Subclass of Transform that transforms null pointer constants into
Index: cpp11-migrate/tool/CMakeLists.txt
===================================================================
--- cpp11-migrate/tool/CMakeLists.txt
+++ cpp11-migrate/tool/CMakeLists.txt
@@ -1,21 +1,19 @@
 set(LLVM_LINK_COMPONENTS support)
 
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-
 set (Cpp11MigrateSources
   Cpp11Migrate.cpp
-  Transforms.cpp
-  Transform.cpp
   )
 
+# FIXME: Lib-ify the transforms to simplify the build rules.
+
 # For each transform subdirectory.
-file(GLOB_RECURSE LoopConvertSources "LoopConvert/*.cpp")
+file(GLOB_RECURSE LoopConvertSources "../LoopConvert/*.cpp")
 list(APPEND Cpp11MigrateSources ${LoopConvertSources})
 
-file(GLOB_RECURSE UseNullptrSources "UseNullptr/*.cpp")
+file(GLOB_RECURSE UseNullptrSources "../UseNullptr/*.cpp")
 list(APPEND Cpp11MigrateSources ${UseNullptrSources})
 
-file(GLOB_RECURSE UseAutoSources "UseAuto/*.cpp")
+file(GLOB_RECURSE UseAutoSources "../UseAuto/*.cpp")
 list(APPEND Cpp11MigrateSources ${UseAutoSources})
 
 add_clang_executable(cpp11-migrate
@@ -27,7 +25,5 @@
   )
 
 target_link_libraries(cpp11-migrate
-  clangTooling
-  clangBasic
-  clangASTMatchers
+  migrateCore
   )
Index: cpp11-migrate/tool/Cpp11Migrate.cpp
===================================================================
--- cpp11-migrate/tool/Cpp11Migrate.cpp
+++ cpp11-migrate/tool/Cpp11Migrate.cpp
@@ -15,8 +15,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Transforms.h"
-#include "Transform.h"
+#include "Core/Transforms.h"
+#include "Core/Transform.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
Index: cpp11-migrate/tool/Makefile
===================================================================
--- cpp11-migrate/tool/Makefile
+++ cpp11-migrate/tool/Makefile
@@ -7,36 +7,40 @@
 #
 ##===----------------------------------------------------------------------===##
 
-CLANG_LEVEL := ../../..
+CLANG_LEVEL := ../../../..
+include $(CLANG_LEVEL)/../../Makefile.config
 
 TOOLNAME = cpp11-migrate
 NO_INSTALL = 1
 
 # No plugins, optimize startup time.
 TOOL_NO_EXPORTS = 1
 
-include $(CLANG_LEVEL)/../../Makefile.config
+SOURCES = Cpp11Migrate.cpp
 
-SOURCES = Cpp11Migrate.cpp Transforms.cpp Transform.cpp
+# FIXME: All these gross relative paths will go away once transforms are lib-ified.
 
 # For each Transform subdirectory add to SOURCES and BUILT_SOURCES.
 # BUILT_SOURCES ensures a subdirectory is created to house object files from
 # transform subdirectories. See below for more on .objdir.
-SOURCES += $(addprefix LoopConvert/,$(notdir $(wildcard $(PROJ_SRC_DIR)/LoopConvert/*.cpp)))
-BUILT_SOURCES = $(ObjDir)/LoopConvert/.objdir
-SOURCES += $(addprefix UseNullptr/,$(notdir $(wildcard $(PROJ_SRC_DIR)/UseNullptr/*.cpp)))
-BUILT_SOURCES += $(ObjDir)/UseNullptr/.objdir
-SOURCES += $(addprefix UseAuto/,$(notdir $(wildcard $(PROJ_SRC_DIR)/UseAuto/*.cpp)))
-BUILT_SOURCES += $(ObjDir)/UseAuto/.objdir
+SOURCES += $(addprefix ../LoopConvert/,$(notdir $(wildcard $(PROJ_SRC_DIR)/../LoopConvert/*.cpp)))
+BUILT_SOURCES = $(ObjDir)/../LoopConvert/.objdir
+SOURCES += $(addprefix ../UseNullptr/,$(notdir $(wildcard $(PROJ_SRC_DIR)/../UseNullptr/*.cpp)))
+BUILT_SOURCES += $(ObjDir)/../UseNullptr/.objdir
+SOURCES += $(addprefix ../UseAuto/,$(notdir $(wildcard $(PROJ_SRC_DIR)/../UseAuto/*.cpp)))
+BUILT_SOURCES += $(ObjDir)/../UseAuto/.objdir
 
 LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc
 USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
 		   clangRewriteFrontend.a clangRewriteCore.a clangParse.a \
 		   clangSema.a clangAnalysis.a \
-		   clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a
+		   clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a \
+			 migrateCore.a
 
 include $(CLANG_LEVEL)/Makefile
 
+CPP.Flags += -I$(PROJ_SRC_DIR)/..
+
 # BUILT_SOURCES gets used as a prereq for many top-level targets. However, at
 # the point those targets are defined, $(ObjDir) hasn't been defined and so the
 # directory to create becomes /<name>/ which is not what we want. So instead,
Index: unittests/cpp11-migrate/CMakeLists.txt
===================================================================
--- unittests/cpp11-migrate/CMakeLists.txt
+++ unittests/cpp11-migrate/CMakeLists.txt
@@ -2,10 +2,15 @@
   support
   )
 
+get_filename_component(CPP11_MIGRATE_SOURCE_DIR
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../cpp11-migrate REALPATH)
+include_directories(${CPP11_MIGRATE_SOURCE_DIR})
+
 add_extra_unittest(Cpp11MigrateTests
   dummy.cpp)
 
 target_link_libraries(Cpp11MigrateTests
+  migrateCore
   clangTooling
   clangBasic
   clangASTMatchers
Index: unittests/cpp11-migrate/Makefile
===================================================================
--- unittests/cpp11-migrate/Makefile
+++ unittests/cpp11-migrate/Makefile
@@ -15,8 +15,10 @@
 USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
 		   clangRewriteFrontend.a clangRewriteCore.a clangParse.a \
 		   clangSema.a clangAnalysis.a \
-		   clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a
+		   clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a \
+			 migrateCore.a
 
 include $(CLANG_LEVEL)/Makefile
 MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1
+CPP.Flags += -I$(PROJ_SRC_DIR)/../../cpp11-migrate
 include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
Index: unittests/cpp11-migrate/TransformTest.cpp
===================================================================
--- /dev/null
+++ unittests/cpp11-migrate/TransformTest.cpp
@@ -0,0 +1,50 @@
+#include "gtest/gtest.h"
+#include "Core/Transform.h"
+
+class DummyTransform : public Transform {
+public:
+  DummyTransform(llvm::StringRef Name) : Transform(Name) {}
+
+  virtual int apply(const FileContentsByPath &,
+                    RiskLevel ,
+                    const clang::tooling::CompilationDatabase &,
+                    const std::vector<std::string> &,
+                    FileContentsByPath &) { return 0; }
+
+  void setAcceptedChanges(unsigned Changes) {
+    Transform::setAcceptedChanges(Changes);
+  }
+  void setRejectedChanges(unsigned Changes) {
+    Transform::setRejectedChanges(Changes);
+  }
+  void setDeferredChanges(unsigned Changes) {
+    Transform::setDeferredChanges(Changes);
+  }
+};
+
+TEST(Transform, Interface) {
+  DummyTransform T("my_transform");
+  ASSERT_EQ("my_transform", T.getName());
+  ASSERT_EQ(0u, T.getAcceptedChanges());
+  ASSERT_EQ(0u, T.getRejectedChanges());
+  ASSERT_EQ(0u, T.getDeferredChanges());
+  ASSERT_FALSE(T.getChangesMade());
+  ASSERT_FALSE(T.getChangesNotMade());
+
+  T.setAcceptedChanges(1);
+  ASSERT_TRUE(T.getChangesMade());
+
+  T.setDeferredChanges(1);
+  ASSERT_TRUE(T.getChangesNotMade());
+
+  T.setRejectedChanges(1);
+  ASSERT_TRUE(T.getChangesNotMade());
+
+  T.Reset();
+  ASSERT_EQ(0u, T.getAcceptedChanges());
+  ASSERT_EQ(0u, T.getRejectedChanges());
+  ASSERT_EQ(0u, T.getDeferredChanges());
+
+  T.setRejectedChanges(1);
+  ASSERT_TRUE(T.getChangesNotMade());
+}
Index: unittests/cpp11-migrate/dummy.cpp
===================================================================
--- unittests/cpp11-migrate/dummy.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "gtest/gtest.h"
-
-// FIXME: Replace this test with something more meaningful.
-TEST(SimpleTest, Test) {
-  ASSERT_TRUE(true);
-}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to