summaryrefslogtreecommitdiffstats
path: root/clang/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
commit32df72db66e83b5c7d5270e899fb3ba78be9d67f (patch)
tree4ed976127d904ccbb71b0aa112d61d22e49e67d7 /clang/lib/Tooling/Tooling.cpp
parentcbabea83d489301bf2ebed61fa79333d9c035607 (diff)
downloadbcm5719-llvm-32df72db66e83b5c7d5270e899fb3ba78be9d67f.tar.gz
bcm5719-llvm-32df72db66e83b5c7d5270e899fb3ba78be9d67f.zip
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. llvm-svn: 156478
Diffstat (limited to 'clang/lib/Tooling/Tooling.cpp')
-rw-r--r--clang/lib/Tooling/Tooling.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index 9b4d4e2e239..abd670380e9 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud