diff options
author | Manuel Klimek <klimek@google.com> | 2013-06-04 14:44:44 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-06-04 14:44:44 +0000 |
commit | d91ac930874389fa2e906d8bcd2456136defd0be (patch) | |
tree | 4c318cc29af5727e10075ce695a88ef9014e60c6 /clang/lib/Tooling/Tooling.cpp | |
parent | a5e536ab0e785dc6fcff76420b65fa592d29b7e0 (diff) | |
download | bcm5719-llvm-d91ac930874389fa2e906d8bcd2456136defd0be.tar.gz bcm5719-llvm-d91ac930874389fa2e906d8bcd2456136defd0be.zip |
Enables chaining of argument adjusters in clang tools.
This enables changing clang-check to get extra arguments.
Patch by Pavel Labath.
llvm-svn: 183227
Diffstat (limited to 'clang/lib/Tooling/Tooling.cpp')
-rw-r--r-- | clang/lib/Tooling/Tooling.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index 52855f657f6..cdb9bc71ee2 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -237,7 +237,7 @@ void ToolInvocation::addFileMappingsTo(SourceManager &Sources) { ClangTool::ClangTool(const CompilationDatabase &Compilations, ArrayRef<std::string> SourcePaths) : Files((FileSystemOptions())), - ArgsAdjuster(new ClangSyntaxOnlyAdjuster()) { + ArgsAdjusters(1, new ClangSyntaxOnlyAdjuster()) { for (unsigned I = 0, E = SourcePaths.size(); I != E; ++I) { SmallString<1024> File(getAbsolutePath(SourcePaths[I])); @@ -264,7 +264,18 @@ void ClangTool::mapVirtualFile(StringRef FilePath, StringRef Content) { } void ClangTool::setArgumentsAdjuster(ArgumentsAdjuster *Adjuster) { - ArgsAdjuster.reset(Adjuster); + clearArgumentsAdjusters(); + appendArgumentsAdjuster(Adjuster); +} + +void ClangTool::appendArgumentsAdjuster(ArgumentsAdjuster *Adjuster) { + ArgsAdjusters.push_back(Adjuster); +} + +void ClangTool::clearArgumentsAdjusters() { + for (unsigned I = 0, E = ArgsAdjusters.size(); I != E; ++I) + delete ArgsAdjusters[I]; + ArgsAdjusters.clear(); } int ClangTool::run(FrontendActionFactory *ActionFactory) { @@ -292,8 +303,9 @@ 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 = - ArgsAdjuster->Adjust(CompileCommands[I].second.CommandLine); + std::vector<std::string> CommandLine = CompileCommands[I].second.CommandLine; + for (unsigned I = 0, E = ArgsAdjusters.size(); I != E; ++I) + CommandLine = ArgsAdjusters[I]->Adjust(CommandLine); assert(!CommandLine.empty()); CommandLine[0] = MainExecutable; // FIXME: We need a callback mechanism for the tool writer to output a |