[llvm-rc] Add ICON and HTML parsing ability (parser, pt 2/8).

This extends the current llvm-rc parser by ICON and HTML resources.
Moreover, some tests have been slightly rewritten.

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36891

llvm-svn: 311939
diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.cpp b/llvm/tools/llvm-rc/ResourceScriptParser.cpp
index 1e9bd46..e4c0f2a 100644
--- a/llvm/tools/llvm-rc/ResourceScriptParser.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptParser.cpp
@@ -63,8 +63,12 @@
   ParseType Result = std::unique_ptr<RCResource>();
   (void)!Result;
 
-  if (TypeToken->equalsLower("ICON"))
+  if (TypeToken->equalsLower("CURSOR"))
+    Result = parseCursorResource();
+  else if (TypeToken->equalsLower("ICON"))
     Result = parseIconResource();
+  else if (TypeToken->equalsLower("HTML"))
+    Result = parseHTMLResource();
   else
     return getExpectedError("resource type", /* IsAlreadyRead = */ true);
 
@@ -219,11 +223,21 @@
   return parseLanguageStmt();
 }
 
+RCParser::ParseType RCParser::parseCursorResource() {
+  ASSIGN_OR_RETURN(Arg, readString());
+  return make_unique<CursorResource>(*Arg);
+}
+
 RCParser::ParseType RCParser::parseIconResource() {
   ASSIGN_OR_RETURN(Arg, readString());
   return make_unique<IconResource>(*Arg);
 }
 
+RCParser::ParseType RCParser::parseHTMLResource() {
+  ASSIGN_OR_RETURN(Arg, readString());
+  return make_unique<HTMLResource>(*Arg);
+}
+
 RCParser::ParseType RCParser::parseStringTableResource() {
   ASSIGN_OR_RETURN(OptStatements, parseOptionalStatements());
   RETURN_IF_ERROR(consumeType(Kind::BlockBegin));
diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.h b/llvm/tools/llvm-rc/ResourceScriptParser.h
index 017e22f..b217a73 100644
--- a/llvm/tools/llvm-rc/ResourceScriptParser.h
+++ b/llvm/tools/llvm-rc/ResourceScriptParser.h
@@ -118,7 +118,9 @@
 
   // Top-level resource parsers.
   ParseType parseLanguageResource();
+  ParseType parseCursorResource();
   ParseType parseIconResource();
+  ParseType parseHTMLResource();
   ParseType parseStringTableResource();
 
   // Optional statement parsers.
diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
index af62e53..f008641 100644
--- a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
@@ -36,10 +36,18 @@
   return OS << "Language: " << Lang << ", Sublanguage: " << SubLang << "\n";
 }
 
+raw_ostream &CursorResource::log(raw_ostream &OS) const {
+  return OS << "Cursor (" << ResName << "): " << CursorLoc << "\n";
+}
+
 raw_ostream &IconResource::log(raw_ostream &OS) const {
   return OS << "Icon (" << ResName << "): " << IconLoc << "\n";
 }
 
+raw_ostream &HTMLResource::log(raw_ostream &OS) const {
+  return OS << "HTML (" << ResName << "): " << HTMLLoc << "\n";
+}
+
 raw_ostream &StringTableResource::log(raw_ostream &OS) const {
   OS << "StringTable:\n";
   OptStatements.log(OS);
diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.h b/llvm/tools/llvm-rc/ResourceScriptStmt.h
index 3ee0962..8ff0e5b 100644
--- a/llvm/tools/llvm-rc/ResourceScriptStmt.h
+++ b/llvm/tools/llvm-rc/ResourceScriptStmt.h
@@ -90,6 +90,17 @@
   raw_ostream &log(raw_ostream &) const override;
 };
 
+// CURSOR resource. Represents a single cursor (".cur") file.
+//
+// Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380920(v=vs.85).aspx
+class CursorResource : public RCResource {
+  StringRef CursorLoc;
+
+public:
+  CursorResource(StringRef Location) : CursorLoc(Location) {}
+  raw_ostream &log(raw_ostream &) const override;
+};
+
 // ICON resource. Represents a single ".ico" file containing a group of icons.
 //
 // Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa381018(v=vs.85).aspx
@@ -101,6 +112,19 @@
   raw_ostream &log(raw_ostream &) const override;
 };
 
+// HTML resource. Represents a local webpage that is to be embedded into the
+// resulting resource file. It embeds a file only - no additional resources
+// (images etc.) are included with this resource.
+//
+// Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa966018(v=vs.85).aspx
+class HTMLResource : public RCResource {
+  StringRef HTMLLoc;
+
+public:
+  HTMLResource(StringRef Location) : HTMLLoc(Location) {}
+  raw_ostream &log(raw_ostream &) const override;
+};
+
 // STRINGTABLE resource. Contains a list of strings, each having its unique ID.
 //
 // Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa381050(v=vs.85).aspx