blob: 7bd4cbd95b1d890258b63a5d786df993b10d3e78 [file] [log] [blame]
Edwin Vane9bd2e1b2012-12-12 14:30:57 +00001//===-- 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 Carruth54e147a2013-01-02 10:29:31 +000033#include "clang/Tooling/CommonOptionsParser.h"
Edwin Vane9bd2e1b2012-12-12 14:30:57 +000034#include "clang/Tooling/Refactoring.h"
35#include "clang/Tooling/Tooling.h"
Edwin Vane9bd2e1b2012-12-12 14:30:57 +000036
37namespace cl = llvm::cl;
38using namespace clang::tooling;
39
40
41int main(int argc, const char **argv) {
42 CommonOptionsParser OptionsParser(argc, argv);
43
44 // TODO: Create transforms requested by command-line.
Edwin Vane9e3c9de2012-12-14 18:59:24 +000045 ClangTool SyntaxTool(OptionsParser.getCompilations(),
46 OptionsParser.getSourcePathList());
Edwin Vane9bd2e1b2012-12-12 14:30:57 +000047
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}