[PATCH] D90109: [clang-tidy] Use ANSI escape codes for --use-color on Windows
David Sanders via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 29 14:17:58 PDT 2020
dsanders11 updated this revision to Diff 301755.
dsanders11 added a comment.
code review changes
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90109/new/
https://reviews.llvm.org/D90109
Files:
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/test/clang-tidy/infrastructure/use-color.cpp
llvm/lib/Support/Windows/Process.inc
Index: llvm/lib/Support/Windows/Process.inc
===================================================================
--- llvm/lib/Support/Windows/Process.inc
+++ llvm/lib/Support/Windows/Process.inc
@@ -327,9 +327,10 @@
if (enable) {
HANDLE Console = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD Mode;
- GetConsoleMode(Console, &Mode);
- Mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
- SetConsoleMode(Console, Mode);
+ if (GetConsoleMode(Console, &Mode) != 0) {
+ Mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+ SetConsoleMode(Console, Mode);
+ }
}
#endif
UseANSI = enable;
Index: clang-tools-extra/test/clang-tidy/infrastructure/use-color.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/use-color.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/use-color.cpp
@@ -5,7 +5,6 @@
// RUN: clang-tidy -config='UseColor: false' -dump-config | FileCheck -check-prefix=CHECK-CONFIG-NO-COLOR %s
// RUN: clang-tidy -help | FileCheck -check-prefix=CHECK-OPT-PRESENT %s
-// REQUIRES: ansi-escape-sequences
// RUN: clang-tidy -checks='-*, modernize-use-override' -extra-arg=-std=c++11 -use-color=false %s | FileCheck -check-prefix=CHECK-NO-COLOR %s
// RUN: clang-tidy -checks='-*, modernize-use-override' -extra-arg=-std=c++11 %s | FileCheck -check-prefix=CHECK-NO-COLOR %s
// RUN: clang-tidy -checks='-*, modernize-use-override' -extra-arg=-std=c++11 -use-color %s | FileCheck -check-prefix=CHECK-COLOR %s
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -110,6 +110,9 @@
DiagOpts->ShowColors = Context.getOptions().UseColor.getValueOr(
llvm::sys::Process::StandardOutHasColors());
DiagPrinter->BeginSourceFile(LangOpts);
+ if (DiagOpts->ShowColors && !llvm::sys::Process::StandardOutIsDisplayed()) {
+ llvm::sys::Process::UseANSIEscapeCodes(true);
+ }
}
SourceManager &getSourceManager() { return SourceMgr; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90109.301755.patch
Type: text/x-patch
Size: 2125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201029/b1b9cace/attachment.bin>
More information about the cfe-commits
mailing list