Edwin Vane | 9bd2e1b | 2012-12-12 14:30:57 +0000 | [diff] [blame] | 1 | //===-- cpp11-migrate/Cpp11Migrate.cpp - Main file C++11 migration tool ---===// |
| 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 implements the C++11 feature migration tool main function |
| 12 | /// and transformation framework. |
| 13 | /// |
| 14 | /// Usage: |
| 15 | /// cpp11-migrate [-p <build-path>] <file1> <file2> ... [-- [compiler-options]] |
| 16 | /// |
| 17 | /// Where <build-path> is a CMake build directory containing a file named |
| 18 | /// compile_commands.json which provides compiler options for building each |
| 19 | /// sourc file. If <build-path> is not provided the compile_commands.json file |
| 20 | /// is searched for through all parent directories. |
| 21 | /// |
| 22 | /// Alternatively, one can provide compile options to be applied to every source |
| 23 | /// file after the optional '--'. |
| 24 | /// |
| 25 | /// <file1>... specify the paths of files in the CMake source tree, with the |
| 26 | /// same requirements as other tools built on LibTooling. |
| 27 | /// |
| 28 | //===----------------------------------------------------------------------===// |
| 29 | |
| 30 | #include "clang/Basic/FileManager.h" |
| 31 | #include "clang/Frontend/CompilerInstance.h" |
| 32 | #include "clang/Frontend/FrontendActions.h" |
Chandler Carruth | 54e147a | 2013-01-02 10:29:31 +0000 | [diff] [blame] | 33 | #include "clang/Tooling/CommonOptionsParser.h" |
Edwin Vane | 9bd2e1b | 2012-12-12 14:30:57 +0000 | [diff] [blame] | 34 | #include "clang/Tooling/Refactoring.h" |
| 35 | #include "clang/Tooling/Tooling.h" |
Edwin Vane | 9bd2e1b | 2012-12-12 14:30:57 +0000 | [diff] [blame] | 36 | |
| 37 | namespace cl = llvm::cl; |
| 38 | using namespace clang::tooling; |
| 39 | |
| 40 | |
| 41 | int main(int argc, const char **argv) { |
| 42 | CommonOptionsParser OptionsParser(argc, argv); |
| 43 | |
| 44 | // TODO: Create transforms requested by command-line. |
Edwin Vane | 9e3c9de | 2012-12-14 18:59:24 +0000 | [diff] [blame] | 45 | ClangTool SyntaxTool(OptionsParser.getCompilations(), |
| 46 | OptionsParser.getSourcePathList()); |
Edwin Vane | 9bd2e1b | 2012-12-12 14:30:57 +0000 | [diff] [blame] | 47 | |
| 48 | // First, let's check to make sure there were no errors. |
| 49 | if (SyntaxTool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>()) != |
| 50 | 0) { |
| 51 | return 1; |
| 52 | } |
| 53 | |
| 54 | // TODO: Apply transforms |
| 55 | |
| 56 | return 0; |
| 57 | } |