13 Commits

Author SHA1 Message Date
Rui Ueyama
ed560ae76a Revert r367649: Improve raw_ostream so that you can "write" colors using operator<<
This reverts commit r367649 in an attempt to unbreak Windows bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367658 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-02 07:22:34 +00:00
Rui Ueyama
9a106d08cf Improve raw_ostream so that you can "write" colors using operator<<
1. raw_ostream supports ANSI colors so that you can write messages to
the termina with colors. Previously, in order to change and reset
color, you had to call `changeColor` and `resetColor` functions,
respectively.

So, if you print out "error: " in red, for example, you had to do
something like this:

  OS.changeColor(raw_ostream::RED);
  OS << "error: ";
  OS.resetColor();

With this patch, you can write the same code as follows:

  OS << raw_ostream::RED << "error: " << raw_ostream::RESET;

2. Add a boolean flag to raw_ostream so that you can disable colored
output. If you disable colors, changeColor, operator<<(Color),
resetColor and other color-related functions have no effect.

Most LLVM tools automatically prints out messages using colors, and
you can disable it by passing a flag such as `--disable-colors`.
This new flag makes it easy to write code that works that way.

Differential Revision: https://reviews.llvm.org/D65564

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367649 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-02 04:48:30 +00:00
Chandler Carruth
6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Joel E. Denny
718a779582 [SourceMgr][FileCheck] Obey -color by extending WithColor
(Relands r344930, reverted in r344935, and now hopefully fixed for
Windows.)

While this change specifically targets FileCheck, it affects any tool
using the same SourceMgr facilities.

Previously, -color was documented in FileCheck's -help output, but
-color had no effect.  Now, -color obeys its documentation: it forces
colors to be used in FileCheck diagnostics even when stderr is not a
terminal.

-color is especially helpful when combined with FileCheck's -v, which
can produce a long series of diagnostics that you might wish to pipe
to a pager, such as less -R.  The WithColor extensions here will also
help to clean up color usage in FileCheck's annotated dump of input,
which is proposed in D52999.

Reviewed By: JDevlieghere, zturner

Differential Revision: https://reviews.llvm.org/D53419

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345202 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-24 21:46:42 +00:00
Aaron Ballman
30353731ce Revert r344930 as it broke some of the bots on Windows.
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/739

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344935 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 18:51:29 +00:00
Joel E. Denny
1aa867a439 [SourceMgr][FileCheck] Obey -color by extending WithColor
While this change specifically targets FileCheck, it affects any tool
using the same SourceMgr facilities.

Previously, -color was documented in FileCheck's -help output, but
-color had no effect.  Now, -color obeys its documentation: it forces
colors to be used in FileCheck diagnostics even when stderr is not a
terminal.

-color is especially helpful when combined with FileCheck's -v, which
can produce a long series of diagnostics that you might wish to pipe
to a pager, such as less -R.  The WithColor extensions here will also
help to clean up color usage in FileCheck's annotated dump of input,
which is proposed in D52999.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D53419

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344930 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 18:00:49 +00:00
Jonas Devlieghere
f7e1e2ecdd [Support] Move header to WithColor header
Forgot to move the CommandLine.h include form the implementation to the
header and didn't notice the failure with my local modules build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333177 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 11:47:20 +00:00
Jonas Devlieghere
2071b7a8b2 [Support] Add color cl category.
This commit adds a color category so tools can document this option and
enables it for dwarfdump and dsymuttil.

rdar://problem/40498996

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333176 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 11:36:57 +00:00
Jonas Devlieghere
e375d515ff [Support] Fix prefix logic in WithColor.
When a prefix is passed, we need to print a colon a space after it, not
just the prefix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330535 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-22 08:01:01 +00:00
Jonas Devlieghere
52107f0189 [Support] Add optional prefix to convenience helpers in WithColor.
Several tools prefix the error/warning/note output with the name of the
tool. One such tool is LLD for example. This commit adds as an optional
'Prefix' argument to the convenience helpers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330526 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-21 21:36:11 +00:00
Jonas Devlieghere
5365e8b418 [Support] Extend WithColor helpers
Although printing warnings and errors to stderr is by far the most
common case, this patch makes it possible to specify any stream.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330094 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-15 08:44:15 +00:00
Jonas Devlieghere
5baab4c85c [Support] Add convenience functions to WithColor. NFC.
Create convenience functions for printing error, warning and note to
stdout. Previously we had similar functions being used in dsymutil, but
given that this pattern is so common it makes sense to make it available
globally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330091 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-14 21:36:42 +00:00
Jonas Devlieghere
01d72e5767 [Support] Move syntax highlighting into support
Move the DWARF syntax highlighting into support. This has several
advantages, most notably that this makes the WithColor RAII wrapper
available outside libDebugInfo. Furthermore, several projects all have
their own code for handling colored output. This provides a place to
centralize it.

Differential revision: https://reviews.llvm.org/D44215

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327108 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-09 09:56:24 +00:00