[PATCH] D105621: [llvm-rc] Make commas in user data structs optional
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 8 13:03:55 PDT 2021
mstorsjo updated this revision to Diff 357333.
mstorsjo added a comment.
Added more cases of multiple commas in tag-user.rc, changed while(); into while() {}, added a separate standalone testcase of a full embedded manifest file without commas between the string literals.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105621/new/
https://reviews.llvm.org/D105621
Files:
llvm/test/tools/llvm-rc/Inputs/inline-manifest.rc
llvm/test/tools/llvm-rc/Inputs/tag-user.rc
llvm/test/tools/llvm-rc/inline-manifest.test
llvm/tools/llvm-rc/ResourceScriptParser.cpp
Index: llvm/tools/llvm-rc/ResourceScriptParser.cpp
===================================================================
--- llvm/tools/llvm-rc/ResourceScriptParser.cpp
+++ llvm/tools/llvm-rc/ResourceScriptParser.cpp
@@ -509,15 +509,14 @@
RETURN_IF_ERROR(consumeType(Kind::BlockBegin));
std::vector<IntOrString> Data;
- // Consume comma before each consecutive token except the first one.
- bool ConsumeComma = false;
while (!consumeOptionalType(Kind::BlockEnd)) {
- if (ConsumeComma)
- RETURN_IF_ERROR(consumeType(Kind::Comma));
- ConsumeComma = true;
-
ASSIGN_OR_RETURN(Item, readIntOrString());
Data.push_back(*Item);
+
+ // There can be zero or more commas after each token (but not before
+ // the first one).
+ while (consumeOptionalType(Kind::Comma)) {
+ }
}
return std::make_unique<UserDefinedResource>(Type, std::move(Data),
Index: llvm/test/tools/llvm-rc/inline-manifest.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-rc/inline-manifest.test
@@ -0,0 +1,23 @@
+; RUN: llvm-rc -no-preprocess /FO %t -- %p/Inputs/inline-manifest.rc
+; RUN: llvm-readobj %t | FileCheck %s
+
+; CHECK: Resource type (int): MANIFEST (ID 24)
+; CHECK-NEXT: Resource name (int): 1
+; CHECK-NEXT: Data version: 0
+; CHECK-NEXT: Memory flags: 0x30
+; CHECK-NEXT: Language ID: 1033
+; CHECK-NEXT: Version (major): 0
+; CHECK-NEXT: Version (minor): 0
+; CHECK-NEXT: Characteristics: 0
+; CHECK-NEXT: Data size: 142
+; CHECK-NEXT: Data: (
+; CHECK-NEXT: 0000: 3C3F786D 6C207665 7273696F 6E3D2231 |<?xml version="1|
+; CHECK-NEXT: 0010: 2E302220 656E636F 64696E67 3D225554 |.0" encoding="UT|
+; CHECK-NEXT: 0020: 462D3822 20737461 6E64616C 6F6E653D |F-8" standalone=|
+; CHECK-NEXT: 0030: 22796573 223F3E0A 3C617373 656D626C |"yes"?>.<assembl|
+; CHECK-NEXT: 0040: 7920786D 6C6E733D 2275726E 3A736368 |y xmlns="urn:sch|
+; CHECK-NEXT: 0050: 656D6173 2D6D6963 726F736F 66742D63 |emas-microsoft-c|
+; CHECK-NEXT: 0060: 6F6D3A61 736D2E76 3122206D 616E6966 |om:asm.v1" manif|
+; CHECK-NEXT: 0070: 65737456 65727369 6F6E3D22 312E3022 |estVersion="1.0"|
+; CHECK-NEXT: 0080: 3E0A3C2F 61737365 6D626C79 3E0A |>.</assembly>.|
+; CHECK-NEXT: )
Index: llvm/test/tools/llvm-rc/Inputs/tag-user.rc
===================================================================
--- llvm/test/tools/llvm-rc/Inputs/tag-user.rc
+++ llvm/test/tools/llvm-rc/Inputs/tag-user.rc
@@ -1,8 +1,8 @@
500 500 {
- 1, 2, 3, 4, 5, "data", L"wide data", 0xABCD, 0xABCDEF01L
+ 1, 2 3, ,4, 5, "da", "ta" L"wide data", 0xABCD, 0xABCDEF01L
}
501 RCDATA {
- 1, 2, 3, 4, 5, "data", L"wide data", 0xABCD, 0xABCDEF01L
+ 1, 2, 3, 4, ,5, "da" "ta" L"wide", L" data", 0xABCD 0xABCDEF01L,
}
NAME1 NAME2 {}
Index: llvm/test/tools/llvm-rc/Inputs/inline-manifest.rc
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-rc/Inputs/inline-manifest.rc
@@ -0,0 +1,6 @@
+1 24
+BEGIN
+ "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>\n"
+ "<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0"">\n"
+ "</assembly>\n"
+END
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105621.357333.patch
Type: text/x-patch
Size: 3195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210708/cc809887/attachment.bin>
More information about the llvm-commits
mailing list