diff options
author | Martin Storsjo <martin@martin.st> | 2018-05-09 18:20:49 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2018-05-09 18:20:49 +0000 |
commit | c1a67857ba0a6ba558818b589fe7c0fcc8f238ae (patch) | |
tree | d78218bbdcfe25836a9d86917d78128728e8af50 /llvm/tools/llvm-rc/ResourceFileWriter.cpp | |
parent | 0ca06f7950e5f08ae06cbadc98bc3622112bc28e (diff) | |
download | bcm5719-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.cpp | 7 |
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); |