Author: alexfh Date: Wed Jun 5 06:33:11 2013 New Revision: 183304 URL: http://llvm.org/viewvc/llvm-project?rev=183304&view=rev Log: 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 Modified: cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp Modified: cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp?rev=183304&r1=183303&r2=183304&view=diff ============================================================================== --- cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp (original) +++ cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp Wed Jun 5 06:33:11 2013 @@ -13,6 +13,8 @@ //===----------------------------------------------------------------------===// #include "clang/Tooling/ArgumentsAdjusters.h" +#include "clang/Basic/LLVM.h" +#include "llvm/ADT/StringRef.h" namespace clang { namespace tooling { @@ -23,8 +25,14 @@ 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. + 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; } _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
