#ifndef LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
#define LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringRef.h"
#include <functional>
#include <string>
#include <vector>
///
/// Command line argument adjuster is responsible for command line arguments
/// modification before the arguments are used to run a frontend action.
-typedef std::function<CommandLineArguments(const CommandLineArguments &)>
- ArgumentsAdjuster;
+typedef std::function<CommandLineArguments(
+ const CommandLineArguments &, StringRef Filename)> ArgumentsAdjuster;
/// \brief Gets an argument adjuster that converts input command line arguments
/// to the "syntax check only" variant.
//===----------------------------------------------------------------------===//
#include "clang/Tooling/ArgumentsAdjusters.h"
-#include "clang/Basic/LLVM.h"
-#include "llvm/ADT/StringRef.h"
namespace clang {
namespace tooling {
/// Add -fsyntax-only option to the commnand line arguments.
ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
- return [](const CommandLineArguments &Args) {
+ return [](const CommandLineArguments &Args, StringRef /*unused*/) {
CommandLineArguments AdjustedArgs;
for (size_t i = 0, e = Args.size(); i != e; ++i) {
StringRef Arg = Args[i];
}
ArgumentsAdjuster getClangStripOutputAdjuster() {
- return [](const CommandLineArguments &Args) {
+ return [](const CommandLineArguments &Args, StringRef /*unused*/) {
CommandLineArguments AdjustedArgs;
for (size_t i = 0, e = Args.size(); i < e; ++i) {
StringRef Arg = Args[i];
ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra,
ArgumentInsertPosition Pos) {
- return [Extra, Pos](const CommandLineArguments &Args) {
+ return [Extra, Pos](const CommandLineArguments &Args, StringRef /*unused*/) {
CommandLineArguments Return(Args);
CommandLineArguments::iterator I;
ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,
ArgumentsAdjuster Second) {
- return [First, Second](const CommandLineArguments &Args) {
- return Second(First(Args));
+ return [First, Second](const CommandLineArguments &Args, StringRef File) {
+ return Second(First(Args, File), File);
};
}
std::vector<std::string> CommandLine = CompileCommand.CommandLine;
if (ArgsAdjuster)
- CommandLine = ArgsAdjuster(CommandLine);
+ CommandLine = ArgsAdjuster(CommandLine, CompileCommand.Filename);
assert(!CommandLine.empty());
CommandLine[0] = MainExecutable;
// FIXME: We need a callback mechanism for the tool writer to output a
bool Found = false;
bool Ran = false;
ArgumentsAdjuster CheckSyntaxOnlyAdjuster =
- [&Found, &Ran](const CommandLineArguments &Args) {
+ [&Found, &Ran](const CommandLineArguments &Args, StringRef /*unused*/) {
Ran = true;
if (std::find(Args.begin(), Args.end(), "-fsyntax-only") != Args.end())
Found = true;