aboutsummaryrefslogtreecommitdiff
path: root/lib/Tooling/Tooling.cpp
diff options
context:
space:
mode:
authorSimon Atanasyan <satanasyan@mips.com>2012-05-09 16:18:30 +0000
committerSimon Atanasyan <satanasyan@mips.com>2012-05-09 16:18:30 +0000
commita01ddc787b5c8b1cf11e975d3586908d3629954c (patch)
tree5358de2a3762116e1e2e6887a43bcd2993859778 /lib/Tooling/Tooling.cpp
parent4c4cc16dbb4ab44909ea3cbb43609ef5ea19b9d2 (diff)
Declare abstract class ArgumentsAdjuster. This abstract interface describes
a command line argument adjuster, which is responsible for command line arguments modification before the arguments are used to run a frontend action. Define class ClangSyntaxOnlyAdjuster implements ArgumentsAdjuster interface. This class converts input command line arguments to the "syntax check only" variant. Reviewed by Manuel Klimek. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156478 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/Tooling.cpp')
-rw-r--r--lib/Tooling/Tooling.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp
index 9b4d4e2e23..abd670380e 100644
--- a/lib/Tooling/Tooling.cpp
+++ b/lib/Tooling/Tooling.cpp
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Tooling/ArgumentsAdjusters.h"
#include "clang/Tooling/Tooling.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Driver/Compilation.h"
@@ -253,7 +254,8 @@ void ToolInvocation::addFileMappingsTo(SourceManager &Sources) {
ClangTool::ClangTool(const CompilationDatabase &Compilations,
ArrayRef<std::string> SourcePaths)
- : Files((FileSystemOptions())) {
+ : Files((FileSystemOptions())),
+ ArgsAdjuster(new ClangSyntaxOnlyAdjuster()) {
llvm::SmallString<1024> BaseDirectory;
if (const char *PWD = ::getenv("PWD"))
BaseDirectory = PWD;
@@ -285,6 +287,10 @@ void ClangTool::mapVirtualFile(StringRef FilePath, StringRef Content) {
MappedFileContents.push_back(std::make_pair(FilePath, Content));
}
+void ClangTool::setArgumentsAdjuster(ArgumentsAdjuster *Adjuster) {
+ ArgsAdjuster.reset(Adjuster);
+}
+
int ClangTool::run(FrontendActionFactory *ActionFactory) {
bool ProcessingFailed = false;
for (unsigned I = 0; I < CompileCommands.size(); ++I) {
@@ -299,8 +305,8 @@ int ClangTool::run(FrontendActionFactory *ActionFactory) {
if (chdir(CompileCommands[I].second.Directory.c_str()))
llvm::report_fatal_error("Cannot chdir into \"" +
CompileCommands[I].second.Directory + "\n!");
- std::vector<std::string> &CommandLine =
- CompileCommands[I].second.CommandLine;
+ std::vector<std::string> CommandLine =
+ ArgsAdjuster->Adjust(CompileCommands[I].second.CommandLine);
llvm::outs() << "Processing: " << File << ".\n";
ToolInvocation Invocation(CommandLine, ActionFactory->create(), &Files);
for (int I = 0, E = MappedFileContents.size(); I != E; ++I) {