Fix Modi and File count if there are more than 65535 modules/files.

These numbers are intended to be capped at 65535, but
`std::max<uint16_t>(UINT16_MAX, N)` always returns N for any N because
the expression is the same as `std::max((uint16_t)UINT16_MAX, (uint16_t)N)`.

llvm-svn: 287060
This commit is contained in:
Rui Ueyama 2016-11-16 00:38:33 +00:00
parent 8c1a9ac52b
commit 507013180e
1 changed files with 2 additions and 2 deletions

View File

@ -185,8 +185,8 @@ Error DbiStreamBuilder::generateFileInfoSubstream() {
WritableStreamRef(FileInfoBuffer).keep_front(NamesOffset);
StreamWriter MetadataWriter(MetadataBuffer);
uint16_t ModiCount = std::min<uint16_t>(UINT16_MAX, ModuleInfos.size());
uint16_t FileCount = std::min<uint16_t>(UINT16_MAX, SourceFileNames.size());
uint16_t ModiCount = std::min<uint32_t>(UINT16_MAX, ModuleInfos.size());
uint16_t FileCount = std::min<uint32_t>(UINT16_MAX, SourceFileNames.size());
if (auto EC = MetadataWriter.writeInteger(ModiCount)) // NumModules
return EC;
if (auto EC = MetadataWriter.writeInteger(FileCount)) // NumSourceFiles