[cfe-commits] r168420 - in /cfe/trunk: lib/Frontend/ASTConsumers.cpp test/Tooling/clang-check-ast-dump.cpp

Dmitri Gribenko gribozavr at gmail.com
Wed Nov 21 02:54:56 PST 2012


Author: gribozavr
Date: Wed Nov 21 04:54:55 2012
New Revision: 168420

URL: http://llvm.org/viewvc/llvm-project?rev=168420&view=rev
Log:
Use color for -ast-dump-filter only when it is supported

Patch by Philip Craig.

Modified:
    cfe/trunk/lib/Frontend/ASTConsumers.cpp
    cfe/trunk/test/Tooling/clang-check-ast-dump.cpp

Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=168420&r1=168419&r2=168420&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Wed Nov 21 04:54:55 2012
@@ -59,9 +59,12 @@
 
     bool TraverseDecl(Decl *D) {
       if (D != NULL && filterMatches(D)) {
-        Out.changeColor(llvm::raw_ostream::BLUE) <<
-            (Dump ? "Dumping " : "Printing ") << getName(D) << ":\n";
-        Out.resetColor();
+        bool ShowColors = Out.has_colors();
+        if (ShowColors)
+          Out.changeColor(llvm::raw_ostream::BLUE);
+        Out << (Dump ? "Dumping " : "Printing ") << getName(D) << ":\n";
+        if (ShowColors)
+          Out.resetColor();
         if (Dump)
           D->dump(Out);
         else

Modified: cfe/trunk/test/Tooling/clang-check-ast-dump.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-ast-dump.cpp?rev=168420&r1=168419&r2=168420&view=diff
==============================================================================
--- cfe/trunk/test/Tooling/clang-check-ast-dump.cpp (original)
+++ cfe/trunk/test/Tooling/clang-check-ast-dump.cpp Wed Nov 21 04:54:55 2012
@@ -8,7 +8,8 @@
 // RUN: clang-check -ast-dump -ast-dump-filter test_namespace::TheClass::theMethod "%s" -- 2>&1 | FileCheck -check-prefix CHECK-FILTER %s
 // CHECK-FILTER-NOT: namespace test_namespace
 // CHECK-FILTER-NOT: class TheClass
-// CHECK-FILTER: int theMethod(int x) (CompoundStmt
+// CHECK-FILTER: {{^}}Dumping test_namespace::TheClass::theMethod
+// CHECK-FILTER-NEXT: {{^}}int theMethod(int x) (CompoundStmt
 // CHECK-FILTER-NEXT:   (ReturnStmt
 // CHECK-FILTER-NEXT:     (BinaryOperator
 //





More information about the cfe-commits mailing list