From e1cf849e828b91c18cc323e6d912e853168c47ea Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 26 Aug 2024 22:08:33 +0200 Subject: [PATCH] [LLD][COFF] Use parentName for import files in toString. (#106104) Improves diagnostic messages. --- lld/COFF/InputFiles.cpp | 2 +- lld/test/COFF/delayimports-error.test | 2 +- lld/test/COFF/duplicate.test | 2 +- lld/test/COFF/implib-machine.s | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index f9a22b0a7a5f0f..3ecd4d241f2cd4 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -61,7 +61,7 @@ static StringRef getBasename(StringRef path) { std::string lld::toString(const coff::InputFile *file) { if (!file) return ""; - if (file->parentName.empty() || file->kind() == coff::InputFile::ImportKind) + if (file->parentName.empty()) return std::string(file->getName()); return (getBasename(file->parentName) + "(" + getBasename(file->getName()) + diff --git a/lld/test/COFF/delayimports-error.test b/lld/test/COFF/delayimports-error.test index cced9fb65e6142..5f45083cf5e613 100644 --- a/lld/test/COFF/delayimports-error.test +++ b/lld/test/COFF/delayimports-error.test @@ -8,7 +8,7 @@ # RUN: /alternatename:__delayLoadHelper2=main /opt:noref >& %t.log # RUN: FileCheck %s < %t.log -# CHECK: cannot delay-load foo.dll due to import of data: __declspec(dllimport) datasym +# CHECK: cannot delay-load foo.lib(foo.dll) due to import of data: __declspec(dllimport) datasym --- !COFF header: diff --git a/lld/test/COFF/duplicate.test b/lld/test/COFF/duplicate.test index 76c88b070ff375..11e5aa06318fe0 100644 --- a/lld/test/COFF/duplicate.test +++ b/lld/test/COFF/duplicate.test @@ -13,5 +13,5 @@ RUN: not lld-link /out:gamma.exe /subsystem:console /entry:mainCRTStartup gamma. CHECK-GAMMA: error: duplicate symbol: __declspec(dllimport) f CHECK-GAMMA: defined at {{.*}}gamma.obj -CHECK-GAMMA: defined at alpha.dll +CHECK-GAMMA: defined at alpha.lib(alpha.dll) diff --git a/lld/test/COFF/implib-machine.s b/lld/test/COFF/implib-machine.s index 32deff0fc25f89..92f01bbc72799b 100644 --- a/lld/test/COFF/implib-machine.s +++ b/lld/test/COFF/implib-machine.s @@ -6,10 +6,10 @@ # RUN: llvm-mc -triple x86_64-windows-msvc %t.dir/test.s -filetype=obj -o %t.dir/test64.obj # RUN: not lld-link -dll -noentry -out:%t32.dll %t.dir/test32.obj %t.dir/test64.lib 2>&1 | FileCheck --check-prefix=ERR32 %s -# ERR32: error: test.dll: machine type x64 conflicts with x86 +# ERR32: error: test64.lib(test.dll): machine type x64 conflicts with x86 # RUN: not lld-link -dll -noentry -out:%t64.dll %t.dir/test64.obj %t.dir/test32.lib 2>&1 | FileCheck --check-prefix=ERR64 %s -# ERR64: error: test.dll: machine type x86 conflicts with x64 +# ERR64: error: test32.lib(test.dll): machine type x86 conflicts with x64 #--- test.s .def @feat.00;