[PATCH] D85183: [llvm-rc] Allow string table values split into multiple string literals

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 4 01:07:59 PDT 2020


mstorsjo created this revision.
mstorsjo added reviewers: amccarth, thakis.
Herald added a project: LLVM.
mstorsjo requested review of this revision.

This can practically easily be a product of combining strings with macros in resource files.

This fixes https://github.com/mstorsjo/llvm-mingw/issues/140.

As string literals within llvm-rc are handled as StringRefs, each referencing an uninterpreted slice of the input file, with actual interpretation of the input string (codepage handling, unescaping etc) done only right before writing them out to disk, it's hard to concatenate them other than just bundling them up in a vector, without rearchitecting a large part of llvm-rc

This matches how the same already is supported in VersionInfoValue, with a std::vector<IntOrString> Values.

MS rc.exe only supports concatenated string literals in version info values (already supported), string tables (implemented in this patch) and user data resources (easily implemented in a separate patch, but hasn't been requested by any end user yet), while GNU windres supports string immediates split into multiple strings anywhere (e.g. like (100 ICON "myicon" ".ico"). Not sure if concatenation in other statements actually is used in the wild though, in resource files normally built by GNU windres.

I have a separate patch that implements concatenation of all input string literals already at the tokenizer stage, which allows any string token to be split up into separate substrings like with GNU windres, without needing custom code for each resource statement that might contain it. That implementation allows simplifying some of the existing code for version info values as well, but probably is a bit more risky.

@hans - This isn't a regression fix, but should be a fairly safe, backportable improvement, if we're still at a stage when we can take that kind of changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85183

Files:
  llvm/test/tools/llvm-rc/Inputs/tag-stringtable-basic.rc
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.h
  llvm/tools/llvm-rc/ResourceScriptParser.cpp
  llvm/tools/llvm-rc/ResourceScriptStmt.cpp
  llvm/tools/llvm-rc/ResourceScriptStmt.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85183.282818.patch
Type: text/x-patch
Size: 6014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200804/2507184e/attachment.bin>


More information about the llvm-commits mailing list