[llvm] r331901 - [llvm-rc] Allow -1 for control IDs in old style dialogs with 16 bit fields
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Wed May 9 11:20:49 PDT 2018
Author: mstorsjo
Date: Wed May 9 11:20:49 2018
New Revision: 331901
URL: http://llvm.org/viewvc/llvm-project?rev=331901&view=rev
Log:
[llvm-rc] Allow -1 for control IDs in old style dialogs with 16 bit fields
-1 is commonly used as ID for controls that one don't want to
refer to later. For DIALOG resources, the IDs are 16 bit numbers,
and -1 gets interpreted as UINT32_MAX earlier, which then later is
too large to write into a uint16_t.
Differential Revision: https://reviews.llvm.org/D46506
Modified:
llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog.rc
llvm/trunk/test/tools/llvm-rc/tag-dialog.test
llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
Modified: llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog.rc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog.rc?rev=331901&r1=331900&r2=331901&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog.rc (original)
+++ llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog.rc Wed May 9 11:20:49 2018
@@ -50,7 +50,7 @@ EmptyOld DIALOG 1, 2, 3, 4 {}
ArgsOld DIALOG 1, 2, 3, 4 {
LTEXT "L", 1, 2, 3, 4, 5
LTEXT "L2", 6, 7, 8, 9, 10, 11
- LTEXT "L3", 12, 13, 14, 15, 16, 17, 18
+ LTEXT "L3", -1, 13, 14, 15, 16, 17, 18
EDITTEXT 19, 20, 21, 22, 23
EDITTEXT 24, 25, 26, 27, 28, 29
Modified: llvm/trunk/test/tools/llvm-rc/tag-dialog.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-rc/tag-dialog.test?rev=331901&r1=331900&r2=331901&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-rc/tag-dialog.test (original)
+++ llvm/trunk/test/tools/llvm-rc/tag-dialog.test Wed May 9 11:20:49 2018
@@ -153,7 +153,7 @@
; DIALOG-NEXT: 0030: 00000000 0B000250 00000000 07000800 |.......P........|
; DIALOG-NEXT: 0040: 09000A00 0600FFFF 82004C00 32000000 |..........L.2...|
; DIALOG-NEXT: 0050: 00000000 11000250 12000000 0D000E00 |.......P........|
-; DIALOG-NEXT: 0060: 0F001000 0C00FFFF 82004C00 33000000 |..........L.3...|
+; DIALOG-NEXT: 0060: 0F001000 FFFFFFFF 82004C00 33000000 |..........L.3...|
; DIALOG-NEXT: 0070: 00000000 00008150 00000000 14001500 |.......P........|
; DIALOG-NEXT: 0080: 16001700 1300FFFF 81000000 00000000 |................|
; DIALOG-NEXT: 0090: 1D008150 00000000 19001A00 1B001C00 |...P............|
Modified: llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp?rev=331901&r1=331900&r2=331901&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp (original)
+++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp Wed May 9 11:20:49 2018
@@ -1008,8 +1008,11 @@ Error ResourceFileWriter::writeSingleDia
// ID; it's 16-bit in DIALOG and 32-bit in DIALOGEX.
if (!IsExtended) {
- RETURN_IF_ERROR(checkNumberFits<uint16_t>(
- Ctl.ID, "Control ID in simple DIALOG resource"));
+ // It's common to use -1, i.e. UINT32_MAX, for controls one doesn't
+ // want to refer to later.
+ if (Ctl.ID != static_cast<uint32_t>(-1))
+ RETURN_IF_ERROR(checkNumberFits<uint16_t>(
+ Ctl.ID, "Control ID in simple DIALOG resource"));
writeInt<uint16_t>(Ctl.ID);
} else {
writeInt<uint32_t>(Ctl.ID);
More information about the llvm-commits
mailing list