summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-replace/tool/ClangReplaceMain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clang-replace/tool/ClangReplaceMain.cpp')
-rw-r--r--clang-tools-extra/clang-replace/tool/ClangReplaceMain.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-replace/tool/ClangReplaceMain.cpp b/clang-tools-extra/clang-replace/tool/ClangReplaceMain.cpp
new file mode 100644
index 00000000000..f085ed8954b
--- /dev/null
+++ b/clang-tools-extra/clang-replace/tool/ClangReplaceMain.cpp
@@ -0,0 +1,50 @@
+//===-- ClangReplaceMain.cpp - Main file for clang-replace 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 provides the main function for the clang-replace tool.
+///
+//===----------------------------------------------------------------------===//
+
+#include "ApplyReplacements.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::replace;
+
+static cl::opt<std::string> Directory(cl::Positional, cl::Required,
+ cl::desc("<Search Root Directory>"));
+
+int main(int argc, char **argv) {
+ cl::ParseCommandLineOptions(argc, argv);
+
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions());
+ DiagnosticsEngine Diagnostics(
+ IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()),
+ DiagOpts.getPtr());
+
+ TUReplacements TUs;
+
+ error_code ErrorCode =
+ collectReplacementsFromDirectory(Directory, TUs, Diagnostics);
+
+ if (ErrorCode) {
+ errs() << "Trouble iterating over directory '" << Directory
+ << "': " << ErrorCode.message() << "\n";
+ return false;
+ }
+
+ FileToReplacementsMap GroupedReplacements;
+ if (mergeAndDeduplicate(TUs, GroupedReplacements, Diagnostics))
+ return 0;
+ return 1;
+}
OpenPOWER on IntegriCloud