//===--- 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"

namespace clang {
namespace tooling {

void ArgumentsAdjuster::anchor() {
}

/// Add -fsyntax-only option to the commnand line arguments.
CommandLineArguments
ClangSyntaxOnlyAdjuster::Adjust(const CommandLineArguments &Args) {
  CommandLineArguments AdjustedArgs = Args;
  // FIXME: Remove options that generate output.
  AdjustedArgs.push_back("-fsyntax-only");
  return AdjustedArgs;
}

} // end namespace tooling
} // end namespace clang


//===--- 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"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/StringRef.h"

namespace clang {
namespace tooling {

void ArgumentsAdjuster::anchor() {
}

/// Add -fsyntax-only option to the commnand line arguments.
CommandLineArguments
ClangSyntaxOnlyAdjuster::Adjust(const CommandLineArguments &Args) {
  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]);
  }
  AdjustedArgs.push_back("-fsyntax-only");
  return AdjustedArgs;
}

} // end namespace tooling
} // end namespace clang


Make clang tools ignore -fcolor-diagnostics and -fdiagnostics-color retrieved from the compilation database.
Make clang tools ignore -fcolor-diagnostics and -fdiagnostics-color retrieved from the compilation database.

Summary:
Clang tools' diagnostic output could be force colored when a command
line from the compilation database contains -fcolor-diagnostics or
-fdiagnostics-color. This is not what we want e.g. for vim integration.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits, revane, jordan_rose

Differential Revision: http://llvm-reviews.chandlerc.com/D917

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@183304 91177308-0d34-0410-b5e6-96231b3b80d8
