[cfe-commits] [clang-tools-extra] r169983 - in /clang-tools-extra/trunk: CMakeLists.txt cpp11-migrate/ cpp11-migrate/CMakeLists.txt cpp11-migrate/Cpp11Migrate.cpp cpp11-migrate/Makefile test/CMakeLists.txt test/cpp11-migrate/ test/cpp11-migrate/syntax_only.cpp test/cpp11-migrate/syntax_xfail.cpp

Edwin Vane edwin.vane at intel.com
Wed Dec 12 06:30:58 PST 2012


Author: revane
Date: Wed Dec 12 08:30:57 2012
New Revision: 169983

URL: http://llvm.org/viewvc/llvm-project?rev=169983&view=rev
Log:
Initial commit for cpp11-migrate tool

- Added directory structures and build system files for the new tool.
- Extremely basic implementation of tool performs only an initial syntax check.
- Basic tests ensure syntax test works as expected.


Added:
    clang-tools-extra/trunk/cpp11-migrate/
    clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt
    clang-tools-extra/trunk/cpp11-migrate/Cpp11Migrate.cpp
    clang-tools-extra/trunk/cpp11-migrate/Makefile
    clang-tools-extra/trunk/test/cpp11-migrate/
    clang-tools-extra/trunk/test/cpp11-migrate/syntax_only.cpp
    clang-tools-extra/trunk/test/cpp11-migrate/syntax_xfail.cpp
Modified:
    clang-tools-extra/trunk/CMakeLists.txt
    clang-tools-extra/trunk/test/CMakeLists.txt

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=169983&r1=169982&r2=169983&view=diff
==============================================================================
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Wed Dec 12 08:30:57 2012
@@ -2,6 +2,7 @@
 add_subdirectory(tool-template)
 add_subdirectory(loop-convert)
 add_subdirectory(clang-format)
+add_subdirectory(cpp11-migrate)
 
 # Add the common testsuite after all the tools.
 add_subdirectory(test)

Added: clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt?rev=169983&view=auto
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt Wed Dec 12 08:30:57 2012
@@ -0,0 +1,12 @@
+set(LLVM_LINK_COMPONENTS support)
+set(LLVM_USED_LIBS clangTooling clangBasic clangAST)
+
+add_clang_executable(cpp11-migrate
+  Cpp11Migrate.cpp
+  )
+
+target_link_libraries(cpp11-migrate
+  clangTooling
+  clangBasic
+  clangASTMatchers
+  )

Added: clang-tools-extra/trunk/cpp11-migrate/Cpp11Migrate.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Cpp11Migrate.cpp?rev=169983&view=auto
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Cpp11Migrate.cpp (added)
+++ clang-tools-extra/trunk/cpp11-migrate/Cpp11Migrate.cpp Wed Dec 12 08:30:57 2012
@@ -0,0 +1,57 @@
+//===-- cpp11-migrate/Cpp11Migrate.cpp - Main file C++11 migration tool ---===//
+//
+//                     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 implements the C++11 feature migration tool main function
+/// and transformation framework.
+///
+/// Usage:
+/// cpp11-migrate [-p <build-path>] <file1> <file2> ... [-- [compiler-options]]
+///
+/// Where <build-path> is a CMake build directory containing a file named
+/// compile_commands.json which provides compiler options for building each
+/// sourc file. If <build-path> is not provided the compile_commands.json file
+/// is searched for through all parent directories.
+///
+/// Alternatively, one can provide compile options to be applied to every source
+/// file after the optional '--'.
+///
+/// <file1>... specify the paths of files in the CMake source tree, with the
+/// same requirements as other tools built on LibTooling.
+///
+//===----------------------------------------------------------------------===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+
+namespace cl = llvm::cl;
+using namespace clang::tooling;
+
+
+int main(int argc, const char **argv) {
+  CommonOptionsParser OptionsParser(argc, argv);
+
+  // TODO: Create transforms requested by command-line.
+  ClangTool SyntaxTool(OptionsParser.GetCompilations(),
+                       OptionsParser.GetSourcePathList());
+
+  // First, let's check to make sure there were no errors.
+  if (SyntaxTool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>()) !=
+      0) {
+    return 1;
+  }
+
+  // TODO: Apply transforms
+
+  return 0;
+}

Added: clang-tools-extra/trunk/cpp11-migrate/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Makefile?rev=169983&view=auto
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Makefile (added)
+++ clang-tools-extra/trunk/cpp11-migrate/Makefile Wed Dec 12 08:30:57 2012
@@ -0,0 +1,26 @@
+##===- 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 := ../../..
+
+TOOLNAME = cpp11-migrate
+NO_INSTALL = 1
+
+# No plugins, optimize startup time.
+TOOL_NO_EXPORTS = 1
+
+include $(CLANG_LEVEL)/../../Makefile.config
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser 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
+
+include $(CLANG_LEVEL)/Makefile
+

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=169983&r1=169982&r2=169983&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Wed Dec 12 08:30:57 2012
@@ -22,7 +22,7 @@
   clang clang-headers FileCheck count not
 
   # Individual tools we test.
-  remove-cstr-calls loop-convert
+  remove-cstr-calls loop-convert cpp11-migrate
   )
 
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"

Added: clang-tools-extra/trunk/test/cpp11-migrate/syntax_only.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/cpp11-migrate/syntax_only.cpp?rev=169983&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/cpp11-migrate/syntax_only.cpp (added)
+++ clang-tools-extra/trunk/test/cpp11-migrate/syntax_only.cpp Wed Dec 12 08:30:57 2012
@@ -0,0 +1,7 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: cpp11-migrate %t.cpp --
+// REQUIRES: shell
+
+int main(int argc, char** argv) {
+  return 0;
+}

Added: clang-tools-extra/trunk/test/cpp11-migrate/syntax_xfail.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/cpp11-migrate/syntax_xfail.cpp?rev=169983&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/cpp11-migrate/syntax_xfail.cpp (added)
+++ clang-tools-extra/trunk/test/cpp11-migrate/syntax_xfail.cpp Wed Dec 12 08:30:57 2012
@@ -0,0 +1,8 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: cpp11-migrate %t.cpp --
+// XFAIL: *
+// REQUIRES: shell
+
+int main(int argc, char** argv) {
+i  return 0;
+}





More information about the cfe-commits mailing list