blob: a69971e006eba4053d68a8ffcc4609f950a46cab [file] [log] [blame]
Simon Atanasyana01ddc72012-05-09 16:18:30 +00001//===--- 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"
Alexander Kornienkoe7b04862013-06-05 11:33:11 +000016#include "clang/Basic/LLVM.h"
17#include "llvm/ADT/StringRef.h"
Simon Atanasyana01ddc72012-05-09 16:18:30 +000018
19namespace clang {
20namespace tooling {
21
David Blaikie025983a2012-05-09 18:31:50 +000022void ArgumentsAdjuster::anchor() {
23}
24
Simon Atanasyana01ddc72012-05-09 16:18:30 +000025/// Add -fsyntax-only option to the commnand line arguments.
26CommandLineArguments
27ClangSyntaxOnlyAdjuster::Adjust(const CommandLineArguments &Args) {
Alexander Kornienkoe7b04862013-06-05 11:33:11 +000028 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 }
Simon Atanasyana01ddc72012-05-09 16:18:30 +000036 AdjustedArgs.push_back("-fsyntax-only");
37 return AdjustedArgs;
38}
39
Pavel Labath63d53352013-06-06 11:52:19 +000040CommandLineArguments
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
Simon Atanasyana01ddc72012-05-09 16:18:30 +000057} // end namespace tooling
58} // end namespace clang
59