This is an archive of the discontinued LLVM Phabricator instance.

[llvm-rc] Allow -1 for control IDs in old style dialogs with 16 bit fields
ClosedPublic

Authored by mstorsjo on May 6 2018, 2:32 PM.

Details

Summary

-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.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.May 6 2018, 2:32 PM
amccarth accepted this revision.May 9 2018, 9:06 AM

LGTM, but consider inline suggestion.

tools/llvm-rc/ResourceFileWriter.cpp
986 ↗(On Diff #145413)

This is fine, but I had to stop and wonder if there's an assumption about two's-complement.

Why not:

if (Ctl.ID != static_cast<uint32_t>(-1))
This revision is now accepted and ready to land.May 9 2018, 9:06 AM
mstorsjo added inline comments.May 9 2018, 9:33 AM
tools/llvm-rc/ResourceFileWriter.cpp
986 ↗(On Diff #145413)

Thanks, that's even more readable, will try that before commiting!

This revision was automatically updated to reflect the committed changes.