[lld] 89285a1 - [lld-macho] Disable colors in errors when not printing to a pty

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 15:52:32 PDT 2020


Author: Jez Ng
Date: 2020-04-29T15:44:35-07:00
New Revision: 89285a1a97c0d9b63617f812f96604d1b0ae7033

URL: https://github.com/llvm/llvm-project/commit/89285a1a97c0d9b63617f812f96604d1b0ae7033
DIFF: https://github.com/llvm/llvm-project/commit/89285a1a97c0d9b63617f812f96604d1b0ae7033.diff

LOG: [lld-macho] Disable colors in errors when not printing to a pty

This makes for better tests (and is just the right thing to do)

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

Added: 
    

Modified: 
    lld/MachO/Driver.cpp
    lld/test/MachO/alignment-too-large.yaml
    lld/test/MachO/arch.s
    lld/test/MachO/duplicate-symbol.s
    lld/test/MachO/entry-symbol.s
    lld/test/MachO/invalid-executable.s
    lld/test/MachO/missing-dylib.s
    lld/test/MachO/no-id-dylink.s
    lld/test/MachO/no-such-file.s
    lld/test/MachO/silent-ignore.test

Removed: 
    


################################################################################
diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index abf5c09c6812..e230fb2c2b88 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -119,6 +119,9 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
   lld::stdoutOS = &stdoutOS;
   lld::stderrOS = &stderrOS;
 
+  stderrOS.enable_colors(stderrOS.has_colors());
+  // TODO: Set up error handler properly, e.g. the errorLimitExceededMsg
+
   MachOOptTable parser;
   opt::InputArgList args = parser.parse(argsArr.slice(1));
 

diff  --git a/lld/test/MachO/alignment-too-large.yaml b/lld/test/MachO/alignment-too-large.yaml
index 18d133f55869..79950524bcf8 100644
--- a/lld/test/MachO/alignment-too-large.yaml
+++ b/lld/test/MachO/alignment-too-large.yaml
@@ -1,7 +1,7 @@
 # RUN: yaml2obj %s -o %t.o
 # RUN: not lld -flavor darwinnew -o %t %t.o 2>&1 | FileCheck %s
 #
-# CHECK: alignment 32 of section __text is too large
+# CHECK: error: alignment 32 of section __text is too large
 --- !mach-o
 FileHeader:
   magic:           0xFEEDFACF

diff  --git a/lld/test/MachO/arch.s b/lld/test/MachO/arch.s
index 313654937c80..e119eb910d94 100644
--- a/lld/test/MachO/arch.s
+++ b/lld/test/MachO/arch.s
@@ -2,7 +2,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-darwin %s -o %t.o
 # RUN: lld -flavor darwinnew -arch x86_64 -o /dev/null %t.o
 # RUN: not lld -flavor darwinnew -arch i386 -o /dev/null %t.o 2>&1 | FileCheck %s
-# CHECK: missing or unsupported -arch i386
+# CHECK: error: missing or unsupported -arch i386
 
 .text
 .global _main

diff  --git a/lld/test/MachO/duplicate-symbol.s b/lld/test/MachO/duplicate-symbol.s
index 47f597f3ec02..d08f34fc0de0 100644
--- a/lld/test/MachO/duplicate-symbol.s
+++ b/lld/test/MachO/duplicate-symbol.s
@@ -3,7 +3,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t-dup.o
 # RUN: not lld -flavor darwinnew -o /dev/null %t-dup.o %t.o 2>&1 | FileCheck %s
 
-# CHECK: duplicate symbol: _main
+# CHECK: error: duplicate symbol: _main
 
 .text
 .global _main

diff  --git a/lld/test/MachO/entry-symbol.s b/lld/test/MachO/entry-symbol.s
index 1890f407f1ad..31ad84047a5c 100644
--- a/lld/test/MachO/entry-symbol.s
+++ b/lld/test/MachO/entry-symbol.s
@@ -2,10 +2,10 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
 # RUN: lld -flavor darwinnew -o /dev/null %t.o -e _not_main
 # RUN: not lld -flavor darwinnew -o /dev/null %t.o -e _missing 2>&1 | FileCheck %s
-# RUN: not lld -flavor darwinnew -o /dev/null %t.o 2>&1 | FileCheck %s --check-prefix=DEFAULT_ENTRY
+# RUN: not lld -flavor darwinnew -o /dev/null %t.o 2>&1 | FileCheck %s --check-prefix=DEFAULT-ENTRY
 
-# CHECK: undefined symbol: _missing
-# DEFAULT_ENTRY: undefined symbol: _main
+# CHECK: error: undefined symbol: _missing
+# DEFAULT-ENTRY: error: undefined symbol: _main
 
 .text
 .global _not_main

diff  --git a/lld/test/MachO/invalid-executable.s b/lld/test/MachO/invalid-executable.s
index 9ad9f51e4170..d8d7accf49c6 100644
--- a/lld/test/MachO/invalid-executable.s
+++ b/lld/test/MachO/invalid-executable.s
@@ -1,8 +1,8 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-darwin %s -o %t.o
 # RUN: lld -flavor darwinnew -o %t %t.o
-# RUN: not lld -flavor darwinnew -o /dev/null %t 2>&1 | FileCheck %s
-# CHECK: unhandled file type
+# RUN: not lld -flavor darwinnew -o /dev/null %t 2>&1 | FileCheck %s -DFILE=%t
+# CHECK: error: [[FILE]]: unhandled file type
 
 .text
 .global _main

diff  --git a/lld/test/MachO/missing-dylib.s b/lld/test/MachO/missing-dylib.s
index d66ff5256401..ad7e51130c40 100644
--- a/lld/test/MachO/missing-dylib.s
+++ b/lld/test/MachO/missing-dylib.s
@@ -2,4 +2,4 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
 # RUN: not lld -flavor darwinnew -Z -o %t -lmissing %t.o 2>&1 | FileCheck %s
 
-# CHECK: library not found for -lmissing
+# CHECK: error: library not found for -lmissing

diff  --git a/lld/test/MachO/no-id-dylink.s b/lld/test/MachO/no-id-dylink.s
index 2fcd10da384c..7353b408b9b1 100644
--- a/lld/test/MachO/no-id-dylink.s
+++ b/lld/test/MachO/no-id-dylink.s
@@ -3,7 +3,7 @@
 # RUN: yaml2obj %p/Inputs/no-id-dylib.yaml -o %t/libnoid.dylib
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/no-id-dylink.o
 # RUN: not lld -flavor darwinnew -o %t/no-id-dylink -Z -L%t -lnoid %t/no-id-dylink.o 2>&1 | FileCheck %s
-# CHECK: dylib {{.*}}libnoid.dylib missing LC_ID_DYLIB load command
+# CHECK: error: dylib {{.*}}libnoid.dylib missing LC_ID_DYLIB load command
 
 .text
 .globl _main

diff  --git a/lld/test/MachO/no-such-file.s b/lld/test/MachO/no-such-file.s
index 840b8f9e8a47..0122c6105fba 100644
--- a/lld/test/MachO/no-such-file.s
+++ b/lld/test/MachO/no-such-file.s
@@ -1,4 +1,4 @@
 # REQUIRES: x86
 # RUN: not lld -flavor darwinnew -o /dev/null %t-no-such-file.o 2>&1 | FileCheck %s
 
-# CHECK: cannot open {{.*}}no-such-file.o
+# CHECK: error: cannot open {{.*}}no-such-file.o

diff  --git a/lld/test/MachO/silent-ignore.test b/lld/test/MachO/silent-ignore.test
index e863aac0b625..de95cff01572 100644
--- a/lld/test/MachO/silent-ignore.test
+++ b/lld/test/MachO/silent-ignore.test
@@ -5,4 +5,4 @@ RUN:   -no_deduplicate \
 RUN:   -lto_library /lib/foo \
 RUN:   -macosx_version_min 0
 RUN: not lld -flavor darwinnew -v --not-an-ignored-argument 2>&1 | FileCheck %s
-CHECK: unknown argument: --not-an-ignored-argument
+CHECK: error: unknown argument: --not-an-ignored-argument


        


More information about the llvm-commits mailing list