summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-04-24 23:26:30 +0000
committerNico Weber <nicolasweber@gmx.de>2019-04-24 23:26:30 +0000
commit23cb79ff93c671f5aa92353737ae4e3309af74fb (patch)
tree6a031a003f40c8d333b7a6b6b1aa27771c1ac6d4 /llvm/lib/Object
parentfb742da34c1393550daf6073374051b16cea6686 (diff)
downloadbcm5719-llvm-23cb79ff93c671f5aa92353737ae4e3309af74fb.tar.gz
bcm5719-llvm-23cb79ff93c671f5aa92353737ae4e3309af74fb.zip
llvm-cvtres: Make new dupe resource error a bit friendlier
For well-known type IDs, include the name of the type. To not duplicate the ID->name map, make llvm-readobj call this new function as well. It has slightly different output, so this also requires updating a few tests. Differential Revision: https://reviews.llvm.org/D61086 llvm-svn: 359153
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/WindowsResource.cpp41
1 files changed, 34 insertions, 7 deletions
diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp
index 813b4b66e3e..bf70e75d3ab 100644
--- a/llvm/lib/Object/WindowsResource.cpp
+++ b/llvm/lib/Object/WindowsResource.cpp
@@ -15,6 +15,7 @@
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/ScopedPrinter.h"
#include <ctime>
#include <queue>
#include <system_error>
@@ -127,8 +128,35 @@ Error ResourceEntryRef::loadNext() {
WindowsResourceParser::WindowsResourceParser() : Root(false) {}
-static Error duplicateResourceError(const ResourceEntryRef& Entry,
- StringRef File1, StringRef File2) {
+void printResourceTypeName(uint16_t TypeID, raw_ostream &OS) {
+ switch (TypeID) {
+ case 1: OS << "CURSOR (ID 1)"; break;
+ case 2: OS << "BITMAP (ID 2)"; break;
+ case 3: OS << "ICON (ID 3)"; break;
+ case 4: OS << "MENU (ID 4)"; break;
+ case 5: OS << "DIALOG (ID 5)"; break;
+ case 6: OS << "STRINGTABLE (ID 6)"; break;
+ case 7: OS << "FONTDIR (ID 7)"; break;
+ case 8: OS << "FONT (ID 8)"; break;
+ case 9: OS << "ACCELERATOR (ID 9)"; break;
+ case 10: OS << "RCDATA (ID 10)"; break;
+ case 11: OS << "MESSAGETABLE (ID 11)"; break;
+ case 12: OS << "GROUP_CURSOR (ID 12)"; break;
+ case 14: OS << "GROUP_ICON (ID 14)"; break;
+ case 16: OS << "VERSIONINFO (ID 16)"; break;
+ case 17: OS << "DLGINCLUDE (ID 17)"; break;
+ case 19: OS << "PLUGPLAY (ID 19)"; break;
+ case 20: OS << "VXD (ID 20)"; break;
+ case 21: OS << "ANICURSOR (ID 21)"; break;
+ case 22: OS << "ANIICON (ID 22)"; break;
+ case 23: OS << "HTML (ID 23)"; break;
+ case 24: OS << "MANIFEST (ID 24)"; break;
+ default: OS << "ID " << TypeID; break;
+ }
+}
+
+static Error makeDuplicateResourceError(const ResourceEntryRef &Entry,
+ StringRef File1, StringRef File2) {
std::string Ret;
raw_string_ostream OS(Ret);
@@ -140,9 +168,8 @@ static Error duplicateResourceError(const ResourceEntryRef& Entry,
if (!convertUTF16ToUTF8String(Entry.getTypeString(), UTF8))
UTF8 = "(failed conversion from UTF16)";
OS << '\"' << UTF8 << '\"';
- } else {
- OS << "ID " << Entry.getTypeID();
- }
+ } else
+ printResourceTypeName(Entry.getTypeID(), OS);
OS << "/name ";
if (Entry.checkNameString()) {
@@ -190,8 +217,8 @@ Error WindowsResourceParser::parse(WindowsResource *WR) {
IsNewTypeString, IsNewNameString, Node);
InputFilenames.push_back(WR->getFileName());
if (!IsNewNode)
- return duplicateResourceError(Entry, InputFilenames[Node->Origin],
- WR->getFileName());
+ return makeDuplicateResourceError(Entry, InputFilenames[Node->Origin],
+ WR->getFileName());
if (IsNewTypeString)
StringTable.push_back(Entry.getTypeString());
OpenPOWER on IntegriCloud