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
This commit is contained in:
parent
037d2b252d
commit
8581648838
|
@ -2,32 +2,5 @@ set(LLVM_LINK_COMPONENTS support)
|
|||
|
||||
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)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
set(LLVM_LINK_COMPONENTS support)
|
||||
|
||||
add_clang_library(migrateCore
|
||||
Transforms.cpp
|
||||
Transform.cpp
|
||||
)
|
||||
target_link_libraries(migrateCore
|
||||
clangTooling
|
||||
clangBasic
|
||||
clangASTMatchers
|
||||
)
|
|
@ -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)/..
|
|
@ -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"
|
|
@ -12,7 +12,7 @@
|
|||
///
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "Transforms.h"
|
||||
#include "Core/Transforms.h"
|
||||
#include "LoopConvert/LoopConvert.h"
|
||||
#include "UseNullptr/UseNullptr.h"
|
||||
#include "UseAuto/UseAuto.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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) > $@
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
set(LLVM_LINK_COMPONENTS support)
|
||||
|
||||
set (Cpp11MigrateSources
|
||||
Cpp11Migrate.cpp
|
||||
)
|
||||
|
||||
# FIXME: Lib-ify the transforms to simplify the build rules.
|
||||
|
||||
# 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
|
||||
migrateCore
|
||||
)
|
|
@ -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"
|
|
@ -0,0 +1,53 @@
|
|||
##===- tools/extra/loop-convert/Makefile ----sssss----------*- Makefile -*-===##
|
||||
#
|
||||
# The LLVM Compiler Infrastructure
|
||||
#
|
||||
# This file is distributed under the University of Illinois Open Source
|
||||
# License. See LICENSE.TXT for details.
|
||||
#
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
CLANG_LEVEL := ../../../..
|
||||
include $(CLANG_LEVEL)/../../Makefile.config
|
||||
|
||||
TOOLNAME = cpp11-migrate
|
||||
NO_INSTALL = 1
|
||||
|
||||
# No plugins, optimize startup time.
|
||||
TOOL_NO_EXPORTS = 1
|
||||
|
||||
SOURCES = Cpp11Migrate.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
|
||||
|
||||
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 \
|
||||
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,
|
||||
# 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) > $@
|
||||
|
Loading…
Reference in New Issue