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

Alexander Kornienko alexfh at google.com
Tue Jun 4 12:48:03 PDT 2013


  Fix.

Hi klimek,

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

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D917?vs=2264&id=2265#toc

Files:
  lib/Tooling/ArgumentsAdjusters.cpp

Index: lib/Tooling/ArgumentsAdjusters.cpp
===================================================================
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ 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,15 @@
 /// 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;
+  AdjustedArgs.reserve(Args.size() + 1);
+  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;
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D917.2.patch
Type: text/x-patch
Size: 1141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130604/a75924f8/attachment.bin>


More information about the cfe-commits mailing list