[llvm] [llvm-rc] Concatenate consecutive string tokens in windres mode (PR #68685)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 05:11:30 PDT 2023


mstorsjo wrote:

> The usual behavior (like in C) is that such concatenation promotes the whole string to be a wide string and testing with windres confirms that it follows that pattern. I used following test:
> 
> ```
> 1 test
> {
>    "aaaa",
>    L"bbbb" "cccc",
> }
> ```
> 
> windres will interpret `"aaaa"` as a narrow string, but `L"bbbb" "cccc"` as a wide string, the same as `L"bbbbcccc"`. Implementing that behavior seems right to me and it means that the concatenation in tokenizer would not need to preserve 'L' part of each component separately and should be able to just concatenate the payload.
> 
> BTW, `"bbbb" L"cccc"` is considered a syntax error by windres.

Actually, it turns out that GNU windres doesn't seem to be doing this on the tokenization level - and `"bbbb" L"cccc"` isn't considered a syntax error in every context, only within the context in your example. E.g. this is totally ok:
```
STRINGTABLE
{
  1 "bbbb" L"cccc"
}
```
And it turns out that we do have such an example among our tests, in `tag-stringtable-basic.rc`, and this file happens to be the dummy test input file for lots of the windres specific tests right now.

I did try implementing this - have a look at this commit. I had to update a bunch of those tests, that use that input file, to use a different one as dummy input.

While this works, I'm not entirely satisfied - as this makes the windres mode error out on a bunch of stuff that GNU windres actually does handle just fine. So with that, I'm considering a totally different approach; instead of trying to match GNU windres in general by merging string literals everywhere, just handle it in the specific cases we've run into. The cases in https://github.com/llvm/llvm-project/issues/51286 are all about filenames to `ICON` or for manifests. So I'll post a separate PR to show what that solution looks like.

https://github.com/llvm/llvm-project/pull/68685


More information about the llvm-commits mailing list