1 //===--- ArgumentsAdjusters.cpp - Command line arguments adjuster ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains definitions of classes which implement ArgumentsAdjuster
13 //===----------------------------------------------------------------------===//
15 #include "clang/Tooling/ArgumentsAdjusters.h"
16 #include "clang/Basic/LLVM.h"
17 #include "llvm/ADT/StringRef.h"
22 void ArgumentsAdjuster::anchor() {
25 /// Add -fsyntax-only option to the commnand line arguments.
27 ClangSyntaxOnlyAdjuster::Adjust(const CommandLineArguments &Args) {
28 CommandLineArguments AdjustedArgs;
29 for (size_t i = 0, e = Args.size(); i != e; ++i) {
30 StringRef Arg = Args[i];
31 // FIXME: Remove options that generate output.
32 if (!Arg.startswith("-fcolor-diagnostics") &&
33 !Arg.startswith("-fdiagnostics-color"))
34 AdjustedArgs.push_back(Args[i]);
36 AdjustedArgs.push_back("-fsyntax-only");
41 ClangStripOutputAdjuster::Adjust(const CommandLineArguments &Args) {
42 CommandLineArguments AdjustedArgs;
43 for (size_t i = 0, e = Args.size(); i < e; ++i) {
44 StringRef Arg = Args[i];
45 if(!Arg.startswith("-o"))
46 AdjustedArgs.push_back(Args[i]);
49 // Output is specified as -o foo. Skip the next argument also.
52 // Else, the output is specified as -ofoo. Just do nothing.
57 } // end namespace tooling
58 } // end namespace clang