llvm.org GIT mirror llvm / d49213a
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359749 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 1 year, 5 months ago
2 changed file(s) with 7 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
119119 const WindowsResource *Owner);
120120
121121 BinaryStreamReader Reader;
122 const WindowsResource *Owner;
122123 bool IsStringType;
123124 ArrayRef Type;
124125 uint16_t TypeID;
4545 support::little);
4646 }
4747
48 // static
4849 Expected>
4950 WindowsResource::createWindowsResource(MemoryBufferRef Source) {
5051 if (Source.getBufferSize() < WIN_RES_MAGIC_SIZE + WIN_RES_NULL_ENTRY_SIZE)
5152 return make_error(
52 "File too small to be a resource file",
53 Source.getBufferIdentifier() + ": too small to be a resource file",
5354 object_error::invalid_file_type);
5455 std::unique_ptr Ret(new WindowsResource(Source));
5556 return std::move(Ret);
5758
5859 Expected WindowsResource::getHeadEntry() {
5960 if (BBS.getLength() < sizeof(WinResHeaderPrefix) + sizeof(WinResHeaderSuffix))
60 return make_error(".res contains no entries",
61 return make_error(getFileName() + " contains no entries",
6162 object_error::unexpected_eof);
6263 return ResourceEntryRef::create(BinaryStreamRef(BBS), this);
6364 }
6465
6566 ResourceEntryRef::ResourceEntryRef(BinaryStreamRef Ref,
6667 const WindowsResource *Owner)
67 : Reader(Ref) {}
68 : Reader(Ref), Owner(Owner) {}
6869
6970 Expected
7071 ResourceEntryRef::create(BinaryStreamRef BSR, const WindowsResource *Owner) {
107108 RETURN_IF_ERROR(Reader.readObject(Prefix));
108109
109110 if (Prefix->HeaderSize < MIN_HEADER_SIZE)
110 return make_error("Header size is too small.",
111 return make_error(Owner->getFileName() +
112 ": header size too small",
111113 object_error::parse_failed);
112114
113115 RETURN_IF_ERROR(readStringOrId(Reader, TypeID, Type, IsStringType));