[llvm-rc] Add user-defined resources parsing ability. [8/8]

This allows llvm-rc to parse user-defined resources (ref:
msdn.microsoft.com/en-us/library/windows/desktop/aa381054.aspx).
These statements either import files, or put the specified raw data in
the resulting resource file.

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

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

llvm-svn: 314478
diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.h b/llvm/tools/llvm-rc/ResourceScriptStmt.h
index b090be4..95890fe 100644
--- a/llvm/tools/llvm-rc/ResourceScriptStmt.h
+++ b/llvm/tools/llvm-rc/ResourceScriptStmt.h
@@ -319,6 +319,24 @@
   raw_ostream &log(raw_ostream &) const override;
 };
 
+// User-defined resource. It is either:
+//   * a link to the file, e.g. NAME TYPE "filename",
+//   * or contains a list of integers and strings, e.g. NAME TYPE {1, "a", 2}.
+class UserDefinedResource : public RCResource {
+  IntOrString Type;
+  StringRef FileLoc;
+  std::vector<IntOrString> Contents;
+  bool IsFileResource;
+
+public:
+  UserDefinedResource(IntOrString ResourceType, StringRef FileLocation)
+      : Type(ResourceType), FileLoc(FileLocation), IsFileResource(true) {}
+  UserDefinedResource(IntOrString ResourceType, std::vector<IntOrString> &&Data)
+      : Type(ResourceType), Contents(std::move(Data)), IsFileResource(false) {}
+
+  raw_ostream &log(raw_ostream &) const override;
+};
+
 // -- VERSIONINFO resource and its helper classes --
 //
 // This resource lists the version information on the executable/library.