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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287060 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rui Ueyama 2016-11-16 00:38:33 +00:00
parent 8833323011
commit d0211181aa

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