aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/WindowsResource.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-05-02 01:52:24 +0000
committerNico Weber <nicolasweber@gmx.de>2019-05-02 01:52:24 +0000
commit413517ecfe7886a212d65123a74a8f6434998698 (patch)
treeb65b6ad857ade8adbd350a740d3203089dc0573f /llvm/lib/Object/WindowsResource.cpp
parentd6b469dd058f9a18781a9ec5e2ee555aedba2c62 (diff)
downloadllvm-413517ecfe7886a212d65123a74a8f6434998698.zip
llvm-413517ecfe7886a212d65123a74a8f6434998698.tar.gz
llvm-413517ecfe7886a212d65123a74a8f6434998698.tar.bz2
lld-link: Make "duplicate resource" error message a bit more concise
Reduces the error message from: lld-link: error: failed to parse .res file: duplicate resource: type STRINGTABLE (ID 6)/name ID 3/language 1033, in test1.res and in test2.res To: lld-link: error: duplicate resource: type STRINGTABLE (ID 6)/name ID 3/language 1033, in test1.res and in test2.res Make sure every error message emitted by cvtres contains the name of at least one ".res" file, so that removing the "failed to parse .res file" string doesn't lose information. Differential Revision: https://reviews.llvm.org/D61388 llvm-svn: 359749
Diffstat (limited to 'llvm/lib/Object/WindowsResource.cpp')
-rw-r--r--llvm/lib/Object/WindowsResource.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp
index 2ad5e94..e841335 100644
--- a/llvm/lib/Object/WindowsResource.cpp
+++ b/llvm/lib/Object/WindowsResource.cpp
@@ -46,11 +46,12 @@ WindowsResource::WindowsResource(MemoryBufferRef Source)
support::little);
}
+// static
Expected<std::unique_ptr<WindowsResource>>
WindowsResource::createWindowsResource(MemoryBufferRef Source) {
if (Source.getBufferSize() < WIN_RES_MAGIC_SIZE + WIN_RES_NULL_ENTRY_SIZE)
return make_error<GenericBinaryError>(
- "File too small to be a resource file",
+ Source.getBufferIdentifier() + ": too small to be a resource file",
object_error::invalid_file_type);
std::unique_ptr<WindowsResource> Ret(new WindowsResource(Source));
return std::move(Ret);
@@ -58,14 +59,14 @@ WindowsResource::createWindowsResource(MemoryBufferRef Source) {
Expected<ResourceEntryRef> WindowsResource::getHeadEntry() {
if (BBS.getLength() < sizeof(WinResHeaderPrefix) + sizeof(WinResHeaderSuffix))
- return make_error<EmptyResError>(".res contains no entries",
+ return make_error<EmptyResError>(getFileName() + " contains no entries",
object_error::unexpected_eof);
return ResourceEntryRef::create(BinaryStreamRef(BBS), this);
}
ResourceEntryRef::ResourceEntryRef(BinaryStreamRef Ref,
const WindowsResource *Owner)
- : Reader(Ref) {}
+ : Reader(Ref), Owner(Owner) {}
Expected<ResourceEntryRef>
ResourceEntryRef::create(BinaryStreamRef BSR, const WindowsResource *Owner) {
@@ -108,7 +109,8 @@ Error ResourceEntryRef::loadNext() {
RETURN_IF_ERROR(Reader.readObject(Prefix));
if (Prefix->HeaderSize < MIN_HEADER_SIZE)
- return make_error<GenericBinaryError>("Header size is too small.",
+ return make_error<GenericBinaryError>(Owner->getFileName() +
+ ": header size too small",
object_error::parse_failed);
RETURN_IF_ERROR(readStringOrId(Reader, TypeID, Type, IsStringType));