[lld] r284634 - Include ARGV[0] in error messages.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 13:05:43 PDT 2016


Author: ruiu
Date: Wed Oct 19 15:05:43 2016
New Revision: 284634

URL: http://llvm.org/viewvc/llvm-project?rev=284634&view=rev
Log:
Include ARGV[0] in error messages.

This is what other linkers and clang driver do.

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

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Error.cpp
    lld/trunk/ELF/Error.h
    lld/trunk/test/ELF/basic.s
    lld/trunk/test/ELF/copy-rel-corrupted.s
    lld/trunk/test/ELF/entry.s
    lld/trunk/test/ELF/linkerscript/diagnostic.s

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=284634&r1=284633&r2=284634&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Oct 19 15:05:43 2016
@@ -41,6 +41,7 @@ LinkerDriver *elf::Driver;
 bool elf::link(ArrayRef<const char *> Args, raw_ostream &Error) {
   HasError = false;
   ErrorOS = &Error;
+  Argv0 = Args[0];
 
   Configuration C;
   LinkerDriver D;

Modified: lld/trunk/ELF/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=284634&r1=284633&r2=284634&view=diff
==============================================================================
--- lld/trunk/ELF/Error.cpp (original)
+++ lld/trunk/ELF/Error.cpp Wed Oct 19 15:05:43 2016
@@ -20,21 +20,22 @@ namespace lld {
 
 bool elf::HasError;
 raw_ostream *elf::ErrorOS;
+StringRef elf::Argv0;
 
 void elf::log(const Twine &Msg) {
   if (Config->Verbose)
-    outs() << Msg << "\n";
+    outs() << Argv0 << ": " << Msg << "\n";
 }
 
 void elf::warn(const Twine &Msg) {
   if (Config->FatalWarnings)
     error(Msg);
   else
-    *ErrorOS << "warning: " << Msg << "\n";
+    *ErrorOS << Argv0 << ": warning: " << Msg << "\n";
 }
 
 void elf::error(const Twine &Msg) {
-  *ErrorOS << "error: " << Msg << "\n";
+  *ErrorOS << Argv0 << ": error: " << Msg << "\n";
   HasError = true;
 }
 
@@ -43,7 +44,7 @@ void elf::error(std::error_code EC, cons
 }
 
 void elf::fatal(const Twine &Msg) {
-  *ErrorOS << "error: " << Msg << "\n";
+  *ErrorOS << Argv0 << ": error: " << Msg << "\n";
   exit(1);
 }
 

Modified: lld/trunk/ELF/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=284634&r1=284633&r2=284634&view=diff
==============================================================================
--- lld/trunk/ELF/Error.h (original)
+++ lld/trunk/ELF/Error.h Wed Oct 19 15:05:43 2016
@@ -33,6 +33,7 @@ namespace elf {
 
 extern bool HasError;
 extern llvm::raw_ostream *ErrorOS;
+extern llvm::StringRef Argv0;
 
 void log(const Twine &Msg);
 void warn(const Twine &Msg);

Modified: lld/trunk/test/ELF/basic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/basic.s?rev=284634&r1=284633&r2=284634&view=diff
==============================================================================
--- lld/trunk/test/ELF/basic.s (original)
+++ lld/trunk/test/ELF/basic.s Wed Oct 19 15:05:43 2016
@@ -207,7 +207,7 @@ _start:
 
 # RUN: not ld.lld -o %t2 2>&1 | \
 # RUN:  FileCheck --check-prefix=NO_INPUT %s
-# NO_INPUT: no input files
+# NO_INPUT: ld.lld{{.*}}: no input files
 
 # RUN: not ld.lld %t.no.such.file -o %t2 2>&1 | \
 # RUN:  FileCheck --check-prefix=CANNOT_OPEN %s

Modified: lld/trunk/test/ELF/copy-rel-corrupted.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/copy-rel-corrupted.s?rev=284634&r1=284633&r2=284634&view=diff
==============================================================================
--- lld/trunk/test/ELF/copy-rel-corrupted.s (original)
+++ lld/trunk/test/ELF/copy-rel-corrupted.s Wed Oct 19 15:05:43 2016
@@ -1,7 +1,7 @@
 // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
 // RUN: llvm-mc %p/Inputs/copy-rel-corrupted.s -o %t2.o -filetype=obj -triple=x86_64-pc-linux
 // RUN: ld.lld %t2.o -o %t2.so -shared
-// RUN: not ld.lld %t.o %t2.so -o %t.exe 2>&1 | FileCheck %s --match-full-lines
+// RUN: not ld.lld %t.o %t2.so -o %t.exe 2>&1 | FileCheck %s
 
 // CHECK: error: cannot create a copy relocation for symbol x
 

Modified: lld/trunk/test/ELF/entry.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/entry.s?rev=284634&r1=284633&r2=284634&view=diff
==============================================================================
--- lld/trunk/test/ELF/entry.s (original)
+++ lld/trunk/test/ELF/entry.s Wed Oct 19 15:05:43 2016
@@ -2,9 +2,9 @@
 
 # RUN: ld.lld -e foobar %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN %s
 # RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=NOENTRY %s
-# RUN: ld.lld %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN2 %s --match-full-lines
+# RUN: ld.lld %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN2 %s
 
-# RUN: ld.lld -shared -e foobar %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN --match-full-lines %s
+# RUN: ld.lld -shared -e foobar %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN %s
 # RUN: ld.lld -shared --fatal-warnings -e entry %t1 -o %t2
 # RUN: ld.lld -shared --fatal-warnings %t1 -o %t2
 

Modified: lld/trunk/test/ELF/linkerscript/diagnostic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/diagnostic.s?rev=284634&r1=284633&r2=284634&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/diagnostic.s (original)
+++ lld/trunk/test/ELF/linkerscript/diagnostic.s Wed Oct 19 15:05:43 2016
@@ -52,7 +52,7 @@
 # RUN: FileCheck -check-prefix=ERR6 %s < %t.log
 # ERR6:      line 1:
 # ERR6-NEXT: UNKNOWN_TAG {
-# RUN: grep '^error: ^' %t.log
+# RUN: grep 'error: ^' %t.log
 
 ## One more check that text of lines and pointer to 'bad' token are working ok.
 # RUN: echo "SECTIONS {" > %t.script
@@ -63,4 +63,4 @@
 # RUN: FileCheck -check-prefix=ERR7 %s < %t.log
 # ERR7:      line 4: malformed number: .temp
 # ERR7-NEXT: boom .temp : { *(.temp) } }
-# RUN: grep '^error:      ^' %t.log
+# RUN: grep 'error:      ^' %t.log




More information about the llvm-commits mailing list