summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc/ResourceFileWriter.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-05-09 18:20:49 +0000
committerMartin Storsjo <martin@martin.st>2018-05-09 18:20:49 +0000
commitc1a67857ba0a6ba558818b589fe7c0fcc8f238ae (patch)
treed78218bbdcfe25836a9d86917d78128728e8af50 /llvm/tools/llvm-rc/ResourceFileWriter.cpp
parent0ca06f7950e5f08ae06cbadc98bc3622112bc28e (diff)
downloadbcm5719-llvm-c1a67857ba0a6ba558818b589fe7c0fcc8f238ae.tar.gz
bcm5719-llvm-c1a67857ba0a6ba558818b589fe7c0fcc8f238ae.zip
[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 llvm-svn: 331901
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceFileWriter.cpp')
-rw-r--r--llvm/tools/llvm-rc/ResourceFileWriter.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
index b2cc2cc42f7..f468fa67f52 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1008,8 +1008,11 @@ Error ResourceFileWriter::writeSingleDialogControl(const Control &Ctl,
// 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);
OpenPOWER on IntegriCloud