[lld] r368409 - [ELF] For VS-style diagnostics, prefer printing full paths in the header.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 9 01:29:04 PDT 2019


Author: ikudrin
Date: Fri Aug  9 01:29:03 2019
New Revision: 368409

URL: http://llvm.org/viewvc/llvm-project?rev=368409&view=rev
Log:
[ELF] For VS-style diagnostics, prefer printing full paths in the header.

The filename part in the message header is used by Visual Studio
to fill Error List so that a user can click on an item and jump
to the mentioned location. If we use only the name of a source file
and not the full path, Visual Studio might be unable to find the right
file or, even worse, show a wrong one.

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

Modified:
    lld/trunk/Common/ErrorHandler.cpp
    lld/trunk/test/ELF/Inputs/vs-diagnostics-duplicate3.s
    lld/trunk/test/ELF/vs-diagnostics-duplicate-split.s
    lld/trunk/test/ELF/vs-diagnostics-duplicate.s
    lld/trunk/test/ELF/vs-diagnostics-dynamic-relocation.s
    lld/trunk/test/ELF/vs-diagnostics-undefined-hidden.s
    lld/trunk/test/ELF/vs-diagnostics-undefined-symbol-3.s

Modified: lld/trunk/Common/ErrorHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/Common/ErrorHandler.cpp?rev=368409&r1=368408&r2=368409&view=diff
==============================================================================
--- lld/trunk/Common/ErrorHandler.cpp (original)
+++ lld/trunk/Common/ErrorHandler.cpp Fri Aug  9 01:29:03 2019
@@ -114,11 +114,18 @@ std::string ErrorHandler::getLocation(co
 
   static std::regex regexes[] = {
       std::regex(
-          R"(^undefined (?:\S+ )?symbol:.*\n>>> referenced by (\S+):(\d+)\n.*)"),
+          R"(^undefined (?:\S+ )?symbol:.*\n)"
+          R"(>>> referenced by .+\((\S+):(\d+)\))"),
+      std::regex(
+          R"(^undefined (?:\S+ )?symbol:.*\n>>> referenced by (\S+):(\d+))"),
       std::regex(R"(^undefined symbol:.*\n>>> referenced by (.*):)"),
       std::regex(
           R"(^duplicate symbol: .*\n>>> defined in (\S+)\n>>> defined in.*)"),
-      std::regex(R"(^duplicate symbol: .*\n>>> defined at (\S+):(\d+).*)"),
+      std::regex(
+          R"(^duplicate symbol: .*\n>>> defined at .+\((\S+):(\d+)\))"),
+      std::regex(R"(^duplicate symbol: .*\n>>> defined at (\S+):(\d+))"),
+      std::regex(
+          R"(.*\n>>> defined in .*\n>>> referenced by .+\((\S+):(\d+)\))"),
       std::regex(R"(.*\n>>> defined in .*\n>>> referenced by (\S+):(\d+))"),
       std::regex(R"((\S+):(\d+): unclosed quote)"),
   };

Modified: lld/trunk/test/ELF/Inputs/vs-diagnostics-duplicate3.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/vs-diagnostics-duplicate3.s?rev=368409&r1=368408&r2=368409&view=diff
==============================================================================
--- lld/trunk/test/ELF/Inputs/vs-diagnostics-duplicate3.s (original)
+++ lld/trunk/test/ELF/Inputs/vs-diagnostics-duplicate3.s Fri Aug  9 01:29:03 2019
@@ -1,6 +1,8 @@
 .file "duplicate3.s"
 
-.global baz
+.global baz, qux
 .text
 baz:
   nop
+qux:
+  nop

Modified: lld/trunk/test/ELF/vs-diagnostics-duplicate-split.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/vs-diagnostics-duplicate-split.s?rev=368409&r1=368408&r2=368409&view=diff
==============================================================================
--- lld/trunk/test/ELF/vs-diagnostics-duplicate-split.s (original)
+++ lld/trunk/test/ELF/vs-diagnostics-duplicate-split.s Fri Aug  9 01:29:03 2019
@@ -2,10 +2,10 @@
 // RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
 // RUN: not ld.lld --vs-diagnostics --shared %t.o %t.o -o /dev/null 2>&1 | FileCheck %s
 
-// CHECK:      duplicate.s(15): error: duplicate symbol: foo
+// CHECK:      /tmp{{/|\\}}duplicate.s(15): error: duplicate symbol: foo
 // CHECK-NEXT: >>> defined at duplicate.s:15 (/tmp{{/|\\}}duplicate.s:15)
 // CHECK-NEXT: >>>{{.*}}.o:(.text+0x{{.+}})
-// CHECK:      duplicate.s(15): error: duplicate symbol: foo
+// CHECK:      /tmp{{/|\\}}duplicate.s(15): error: duplicate symbol: foo
 // CHECK-NEXT: >>> defined at duplicate.s:15 (/tmp{{/|\\}}duplicate.s:15)
 // CHECK-NEXT: >>>{{.*}}.o:(.text+0x{{.+}})
 

Modified: lld/trunk/test/ELF/vs-diagnostics-duplicate.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/vs-diagnostics-duplicate.s?rev=368409&r1=368408&r2=368409&view=diff
==============================================================================
--- lld/trunk/test/ELF/vs-diagnostics-duplicate.s (original)
+++ lld/trunk/test/ELF/vs-diagnostics-duplicate.s Fri Aug  9 01:29:03 2019
@@ -24,7 +24,14 @@
 // CHECK-NEXT: >>> defined at duplicate3.s
 // CHECK-NEXT: >>>            {{.*}}3.o:(.text+0x{{.+}})
 
-.global _start, foo, bar, baz
+// Check that we prefer using the full path of a source file.
+// CHECK:      /tmp{{/|\\}}duplicate.s(33): error: duplicate symbol: qux
+// CHECK-NEXT: >>> defined at duplicate.s:33 (/tmp{{/|\\}}duplicate.s:33)
+// CHECK-NEXT: >>> {{.*}}1.o:(.text+0x{{.+}})
+// CHECK-NEXT: >>> defined at duplicate3.s
+// CHECK-NEXT: >>>            {{.*}}3.o:(.text+0x{{.+}})
+
+.global _start, foo, bar, baz, qux
 .text
 _start:
   nop
@@ -42,6 +49,11 @@ bar:
 baz:
   nop
 
+.file 2 "/tmp" "duplicate.s"
+.loc 2 33
+qux:
+  nop
+
 .section .debug_abbrev,"", at progbits
   .byte  1                      # Abbreviation Code
   .byte 17                      # DW_TAG_compile_unit

Modified: lld/trunk/test/ELF/vs-diagnostics-dynamic-relocation.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/vs-diagnostics-dynamic-relocation.s?rev=368409&r1=368408&r2=368409&view=diff
==============================================================================
--- lld/trunk/test/ELF/vs-diagnostics-dynamic-relocation.s (original)
+++ lld/trunk/test/ELF/vs-diagnostics-dynamic-relocation.s Fri Aug  9 01:29:03 2019
@@ -7,12 +7,23 @@
 // CHECK-NEXT: >>> referenced by dyn.s:15
 // CHECK-NEXT: >>>{{.*}}.o:(.text+0x{{.+}})
 
+// CHECK: /tmp{{/|\\}}dyn.s(20): error: can't create dynamic relocation {{.*}}
+// CHECK-NEXT: >>> defined in {{.*}}.o
+// CHECK-NEXT: >>> referenced by dyn.s:20 (/tmp{{/|\\}}dyn.s:20)
+// CHECK-NEXT: >>>{{.*}}.o:(.text+0x{{.+}})
+
 .file 1 "dyn.s"
 .loc 1 15
 
 foo:
 .quad foo
 
+.file 2 "/tmp" "dyn.s"
+.loc 2 20
+
+bar:
+.quad bar
+
 .section .debug_abbrev,"", at progbits
   .byte  1                      # Abbreviation Code
   .byte 17                      # DW_TAG_compile_unit

Modified: lld/trunk/test/ELF/vs-diagnostics-undefined-hidden.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/vs-diagnostics-undefined-hidden.s?rev=368409&r1=368408&r2=368409&view=diff
==============================================================================
--- lld/trunk/test/ELF/vs-diagnostics-undefined-hidden.s (original)
+++ lld/trunk/test/ELF/vs-diagnostics-undefined-hidden.s Fri Aug  9 01:29:03 2019
@@ -9,16 +9,22 @@
 // CHECK:      undef.s(27): error: undefined protected symbol: bar
 // CHECK-NEXT: >>> referenced by undef.s:27
 
+// CHECK:      /tmp{{/|\\}}undef.s(13): error: undefined protected symbol: baz
+// CHECK-NEXT: >>> referenced by undef.s:13 (/tmp{{/|\\}}undef.s:13)
+
 .file 1 "undef.s"
+.file 2 "/tmp" "undef.s"
 
 .hidden foo
-.protected bar
+.protected bar, baz
 .text
 _start:
 .loc 1 15
   jmp foo
 .loc 1 27
   jmp bar
+.loc 2 13
+  jmp baz
 
 .section .debug_abbrev,"", at progbits
   .byte  1                      # Abbreviation Code

Modified: lld/trunk/test/ELF/vs-diagnostics-undefined-symbol-3.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/vs-diagnostics-undefined-symbol-3.s?rev=368409&r1=368408&r2=368409&view=diff
==============================================================================
--- lld/trunk/test/ELF/vs-diagnostics-undefined-symbol-3.s (original)
+++ lld/trunk/test/ELF/vs-diagnostics-undefined-symbol-3.s Fri Aug  9 01:29:03 2019
@@ -10,13 +10,21 @@
 // CHECK:      >>> referenced by undef3.s:15
 // CHECK-NEXT: >>> {{.*}}1.o:(.text+0x{{.+}})
 
+// ERR:        /tmp{{/|\\}}undef3.s(20): error: undefined symbol: bar
+// WARN:       /tmp{{/|\\}}undef3.s(20): warning: undefined symbol: bar
+// CHECK:      >>> referenced by undef3.s:20 (/tmp{{/|\\}}undef3.s:20)
+// CHECK-NEXT: >>> {{.*}}1.o:(.text+0x{{.+}})
+
 .file 1 "undef3.s"
+.file 2 "/tmp" "undef3.s"
 
-.global _start, foo
+.global _start, foo, bar
 .text
 _start:
 .loc 1 15
   jmp foo
+.loc 2 20
+  jmp bar
 
 .section .debug_abbrev,"", at progbits
   .byte  1                      # Abbreviation Code




More information about the llvm-commits mailing list