2012-05-10 00:18:30 +08:00
|
|
|
//===--- ArgumentsAdjusters.cpp - Command line arguments adjuster ---------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains definitions of classes which implement ArgumentsAdjuster
|
|
|
|
// interface.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Tooling/ArgumentsAdjusters.h"
|
2013-06-05 19:33:11 +08:00
|
|
|
#include "clang/Basic/LLVM.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2012-05-10 00:18:30 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tooling {
|
|
|
|
|
2012-05-10 02:31:50 +08:00
|
|
|
void ArgumentsAdjuster::anchor() {
|
|
|
|
}
|
|
|
|
|
2012-05-10 00:18:30 +08:00
|
|
|
/// Add -fsyntax-only option to the commnand line arguments.
|
|
|
|
CommandLineArguments
|
|
|
|
ClangSyntaxOnlyAdjuster::Adjust(const CommandLineArguments &Args) {
|
2013-06-05 19:33:11 +08:00
|
|
|
CommandLineArguments AdjustedArgs;
|
|
|
|
for (size_t i = 0, e = Args.size(); i != e; ++i) {
|
|
|
|
StringRef Arg = Args[i];
|
|
|
|
// FIXME: Remove options that generate output.
|
|
|
|
if (!Arg.startswith("-fcolor-diagnostics") &&
|
|
|
|
!Arg.startswith("-fdiagnostics-color"))
|
|
|
|
AdjustedArgs.push_back(Args[i]);
|
|
|
|
}
|
2012-05-10 00:18:30 +08:00
|
|
|
AdjustedArgs.push_back("-fsyntax-only");
|
|
|
|
return AdjustedArgs;
|
|
|
|
}
|
|
|
|
|
2013-06-06 19:52:19 +08:00
|
|
|
CommandLineArguments
|
|
|
|
ClangStripOutputAdjuster::Adjust(const CommandLineArguments &Args) {
|
|
|
|
CommandLineArguments AdjustedArgs;
|
|
|
|
for (size_t i = 0, e = Args.size(); i < e; ++i) {
|
|
|
|
StringRef Arg = Args[i];
|
|
|
|
if(!Arg.startswith("-o"))
|
|
|
|
AdjustedArgs.push_back(Args[i]);
|
|
|
|
|
|
|
|
if(Arg == "-o") {
|
|
|
|
// Output is specified as -o foo. Skip the next argument also.
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
// Else, the output is specified as -ofoo. Just do nothing.
|
|
|
|
}
|
|
|
|
return AdjustedArgs;
|
|
|
|
}
|
|
|
|
|
2012-05-10 00:18:30 +08:00
|
|
|
} // end namespace tooling
|
|
|
|
} // end namespace clang
|
|
|
|
|