1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[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
This commit is contained in:
Martin Storsjö 2021-07-23 00:36:05 +03:00
parent 41668e0357
commit ea4f7bb1a3
5 changed files with 7 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,5 @@
; RUN: llvm-rc -no-preprocess /FO %t.res -- %p/Inputs/resname-string.rc
; RUN: llvm-readobj %t.res | FileCheck %s
; CHECK: Resource name (string): STRINGNAME
; CHECK: Resource name (string): NAME-WITH-DASHES/AND/SLASHES

View File

@ -27,6 +27,7 @@
; CHECK-NEXT: BlockEnd: End
; CHECK-NEXT: Identifier: He11o
; CHECK-NEXT: Identifier: LLVM
; CHECK-NEXT: Identifier: identifier-with-dashes
; CHECK-NEXT: String: "RC string test."
; CHECK-NEXT: Comma: ,
; CHECK-NEXT: String: L"Another RC string test.'&{"

View File

@ -288,7 +288,7 @@ bool Tokenizer::canContinueIdentifier() const {
assert(!streamEof());
const char CurChar = Data[Pos];
return std::isalnum(CurChar) || CurChar == '_' || CurChar == '.' ||
CurChar == '/' || CurChar == '\\';
CurChar == '/' || CurChar == '\\' || CurChar == '-';
}
bool Tokenizer::canStartInt() const {