[llvm-rc] Don't interpret integer literals as octal numbers in rc.exe mode #166915
+90
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It turns out that rc.exe doesn't interpret integer literals as octal numbers - but GNU windres does. Previously, llvm-rc did interpret them as octal.
Fix the issue by stripping away the leading zeros during tokenization. The alternative (which would be somewhat cleaner, as visible in tokenizer.test) would be to retain them in the RCToken object, but strip them out before calling
StringRef::getAsInteger. Alternatively to handle the radix detection locally in llvm-rc code and not rely on getAsInteger to autodetect it. Both of those solutions require propagating the IsWindres flag so that it is available within RCToken, or at least when calling RCToken::intValue().
Fixes: #144723