diff options
author | Nico Weber <nicolasweber@gmx.de> | 2012-08-30 02:02:19 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2012-08-30 02:02:19 +0000 |
commit | 566698851d76416129cd20ceea02bdd697934c5c (patch) | |
tree | 1bbc93b20d87d1c29fe6fa9696a3015b940b61d8 /lib/Tooling/Tooling.cpp | |
parent | 642214936430d2258318f2022184c1709dfa16d3 (diff) |
Tooling: Add a runToolOnCodeWithArgs() function that allows
passing additional parameters to a tool.
Use this to fix a FIXME in testing code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/Tooling.cpp')
-rw-r--r-- | lib/Tooling/Tooling.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp index e93e0c97f7..0e91c0617d 100644 --- a/lib/Tooling/Tooling.cpp +++ b/lib/Tooling/Tooling.cpp @@ -97,17 +97,22 @@ static clang::CompilerInvocation *newInvocation( bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code, const Twine &FileName) { + return runToolOnCodeWithArgs( + ToolAction, Code, std::vector<std::string>(), FileName); +} + +bool runToolOnCodeWithArgs(clang::FrontendAction *ToolAction, const Twine &Code, + const std::vector<std::string> &Args, + const Twine &FileName) { SmallString<16> FileNameStorage; StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage); - const char *const CommandLine[] = { - "clang-tool", "-fsyntax-only", FileNameRef.data() - }; + std::vector<std::string> Commands; + Commands.push_back("clang-tool"); + Commands.push_back("-fsyntax-only"); + Commands.insert(Commands.end(), Args.begin(), Args.end()); + Commands.push_back(FileNameRef.data()); FileManager Files((FileSystemOptions())); - ToolInvocation Invocation( - std::vector<std::string>( - CommandLine, - CommandLine + llvm::array_lengthof(CommandLine)), - ToolAction, &Files); + ToolInvocation Invocation(Commands, ToolAction, &Files); SmallString<1024> CodeStorage; Invocation.mapVirtualFile(FileNameRef, |