summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc/ResourceFileWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceFileWriter.cpp')
-rw-r--r--llvm/tools/llvm-rc/ResourceFileWriter.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
index f41ffcc8ac5..1d23fb966f6 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -298,6 +298,10 @@ Error ResourceFileWriter::visitStringTableResource(const RCResource *Base) {
return Error::success();
}
+Error ResourceFileWriter::visitUserDefinedResource(const RCResource *Res) {
+ return writeResource(Res, &ResourceFileWriter::writeUserDefinedBody);
+}
+
Error ResourceFileWriter::visitVersionInfoResource(const RCResource *Res) {
return writeResource(Res, &ResourceFileWriter::writeVersionInfoBody);
}
@@ -1048,6 +1052,43 @@ Error ResourceFileWriter::dumpAllStringTables() {
return Error::success();
}
+// --- UserDefinedResource helpers. --- //
+
+Error ResourceFileWriter::writeUserDefinedBody(const RCResource *Base) {
+ auto *Res = cast<UserDefinedResource>(Base);
+
+ if (Res->IsFileResource)
+ return appendFile(Res->FileLoc);
+
+ for (auto &Elem : Res->Contents) {
+ if (Elem.isInt()) {
+ RETURN_IF_ERROR(
+ checkRCInt(Elem.getInt(), "Number in user-defined resource"));
+ writeRCInt(Elem.getInt());
+ continue;
+ }
+
+ SmallVector<UTF16, 128> ProcessedString;
+ bool IsLongString;
+ RETURN_IF_ERROR(processString(Elem.getString(),
+ NullHandlingMethod::UserResource,
+ IsLongString, ProcessedString));
+
+ for (auto Ch : ProcessedString) {
+ if (IsLongString) {
+ writeObject(ulittle16_t(Ch));
+ continue;
+ }
+
+ RETURN_IF_ERROR(checkNumberFits<uint8_t>(
+ Ch, "Character in narrow string in user-defined resoutce"));
+ writeObject(uint8_t(Ch));
+ }
+ }
+
+ return Error::success();
+}
+
// --- VersionInfoResourceResource helpers. --- //
Error ResourceFileWriter::writeVersionInfoBlock(const VersionInfoBlock &Blk) {
OpenPOWER on IntegriCloud