blob: 0e72046237be31efb53a1a7f7b9d696807e410b1 [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"
33#include "clang/Tooling/Refactoring.h"
34#include "clang/Tooling/Tooling.h"
35#include "clang/Tooling/CommonOptionsParser.h"
36
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.
45 ClangTool SyntaxTool(OptionsParser.GetCompilations(),
46 OptionsParser.GetSourcePathList());
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}