summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/ArgumentsAdjusters.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-06-05 11:33:11 +0000
committerAlexander Kornienko <alexfh@google.com>2013-06-05 11:33:11 +0000
commitafd5701dc39a87512a2fd4eb395159d21f7979ec (patch)
tree12d7ef703f53ad48fd3b21012c8b720743d9adca /clang/lib/Tooling/ArgumentsAdjusters.cpp
parent15a5eea3a14db23adeda183fe5d481434f6e026c (diff)
downloadbcm5719-llvm-afd5701dc39a87512a2fd4eb395159d21f7979ec.tar.gz
bcm5719-llvm-afd5701dc39a87512a2fd4eb395159d21f7979ec.zip
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 llvm-svn: 183304
Diffstat (limited to 'clang/lib/Tooling/ArgumentsAdjusters.cpp')
-rw-r--r--clang/lib/Tooling/ArgumentsAdjusters.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp b/clang/lib/Tooling/ArgumentsAdjusters.cpp
index 31dd4659958..c44b20dd5a8 100644
--- a/clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -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;
}
OpenPOWER on IntegriCloud