1//===--- ArgumentsAdjusters.cpp - Command line arguments adjuster ---------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file contains definitions of classes which implement ArgumentsAdjuster 11// interface. 12// 13//===----------------------------------------------------------------------===// 14 15#include "clang/Tooling/ArgumentsAdjusters.h" 16#include "clang/Basic/LLVM.h" 17#include "llvm/ADT/StringRef.h" 18 19namespace clang { 20namespace tooling { 21 22void ArgumentsAdjuster::anchor() { 23} 24 25/// Add -fsyntax-only option to the commnand line arguments. 26CommandLineArguments 27ClangSyntaxOnlyAdjuster::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]); 35 } 36 AdjustedArgs.push_back("-fsyntax-only"); 37 return AdjustedArgs; 38} 39 40CommandLineArguments 41ClangStripOutputAdjuster::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]); 47 48 if(Arg == "-o") { 49 // Output is specified as -o foo. Skip the next argument also. 50 ++i; 51 } 52 // Else, the output is specified as -ofoo. Just do nothing. 53 } 54 return AdjustedArgs; 55} 56 57} // end namespace tooling 58} // end namespace clang 59 60