[llvm-rc] Allow dashes as part of resource name strings
authorMartin Storsjö <martin@martin.st>
Thu, 22 Jul 2021 21:36:05 +0000 (00:36 +0300)
committerMartin Storsjö <martin@martin.st>
Fri, 23 Jul 2021 20:05:20 +0000 (23:05 +0300)
commit0a1683f8cc0df2889f1d86da7a795914f07e5599
tree1e4f631a4271c9fc62d2b9c3c1f01a499b965f45
parent04e8d0b62dca05c396422048b467bea31988cac3
[llvm-rc] Allow dashes as part of resource name strings

This matches what MS rc.exe allows in practice. I'm not aware of
any legal syntax case that are broken by allowing dashes as part
of what the tokenizer considers an Identifier - but I'm not
very well versed in the RC syntax either, can @amccarth think of
any case that would be broken by this?

This fixes downstream bug
https://github.com/msys2/MINGW-packages/issues/9180.

Additionally, rc.exe allows such resource name strings to be surrounded
by quotes, ending up with e.g.

    Resource name (string): "QUOTEDNAME"

(i.e., the quotes end up as part of the string), which llvm-rc doesn't
support yet either. (I'm not aware of such cases in the wild though,
but resource string names with dashes do exist.)

This also allows including files with unquoted paths, with filenames
containing dashes (which fixes
https://github.com/msys2/MINGW-packages/issues/9130, which has been
worked around differently so far).

Differential Revision: https://reviews.llvm.org/D106598
llvm/test/tools/llvm-rc/Inputs/resname-string.rc [new file with mode: 0644]
llvm/test/tools/llvm-rc/Inputs/tokens.rc
llvm/test/tools/llvm-rc/resname-string.test [new file with mode: 0644]
llvm/test/tools/llvm-rc/tokenizer.test
llvm/tools/llvm-rc/ResourceScriptToken.cpp