llvm.org GIT mirror llvm / 22e5490
lld-link: Add /force:multipleres extension to make dupe resource diag non-fatal As a side benefit, lld-link now reports more than one duplicate resource entry before exiting with an error even if the new flag is not passed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359829 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 3 months ago
3 changed file(s) with 16 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
151151 public:
152152 class TreeNode;
153153 WindowsResourceParser();
154 Error parse(WindowsResource *WR);
154 Error parse(WindowsResource *WR, std::vector &Duplicates);
155155 void printTree(raw_ostream &OS) const;
156156 const TreeNode &getTree() const { return Root; }
157157 const ArrayRef> getData() const { return Data; }
167167 return convertUTF16ToUTF8String(makeArrayRef(EndianCorrectedSrc), Out);
168168 }
169169
170 static Error makeDuplicateResourceError(const ResourceEntryRef &Entry,
171 StringRef File1, StringRef File2) {
170 static std::string makeDuplicateResourceError(
171 const ResourceEntryRef &Entry, StringRef File1, StringRef File2) {
172172 std::string Ret;
173173 raw_string_ostream OS(Ret);
174174
196196 OS << "/language " << Entry.getLanguage() << ", in " << File1 << " and in "
197197 << File2;
198198
199 return make_error(OS.str(), object_error::parse_failed);
200 }
201
202 Error WindowsResourceParser::parse(WindowsResource *WR) {
199 return OS.str();
200 }
201
202 Error WindowsResourceParser::parse(WindowsResource *WR,
203 std::vector &Duplicates) {
203204 auto EntryOrErr = WR->getHeadEntry();
204205 if (!EntryOrErr) {
205206 auto E = EntryOrErr.takeError();
228229 bool IsNewNode = Root.addEntry(Entry, InputFilenames.size(),
229230 IsNewTypeString, IsNewNameString, Node);
230231 InputFilenames.push_back(WR->getFileName());
231 if (!IsNewNode)
232 return makeDuplicateResourceError(Entry, InputFilenames[Node->Origin],
233 WR->getFileName());
232 if (!IsNewNode) {
233 Duplicates.push_back(makeDuplicateResourceError(
234 Entry, InputFilenames[Node->Origin], WR->getFileName()));
235 }
234236
235237 if (IsNewTypeString)
236238 StringTable.push_back(Entry.getTypeString());
182182 outs() << "Number of resources: " << EntryNumber << "\n";
183183 }
184184
185 error(Parser.parse(RF));
185 std::vector Duplicates;
186 error(Parser.parse(RF, Duplicates));
187 for (const auto& DupeDiag : Duplicates)
188 reportError(DupeDiag);
186189 }
187190
188191 if (Verbose) {