Skip to content

[ClangImporter] Handle lookup tables with many entries #17265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/ClangImporter/SwiftLookupTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ namespace {
if (key.Kind == DeclBaseName::Kind::Normal) {
keyLength += key.Name.size(); // The name's length
}
assert(keyLength == static_cast<uint16_t>(keyLength));

// # of entries
uint32_t dataLength = sizeof(uint16_t);
Expand All @@ -982,7 +983,7 @@ namespace {

endian::Writer<little> writer(out);
writer.write<uint16_t>(keyLength);
writer.write<uint16_t>(dataLength);
writer.write<uint32_t>(dataLength);
return { keyLength, dataLength };
}

Expand Down Expand Up @@ -1066,10 +1067,12 @@ namespace {
uint32_t keyLength = 1;
if (SwiftLookupTable::contextRequiresName(key.first))
keyLength += key.second.size();
assert(keyLength == static_cast<uint16_t>(keyLength));

// # of entries
uint32_t dataLength =
sizeof(uint16_t) + sizeof(uint64_t) * data.size();
assert(dataLength == static_cast<uint16_t>(dataLength));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t this be checking against uint32_t?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is a different table, which I didn't change.


endian::Writer<little> writer(out);
writer.write<uint16_t>(keyLength);
Expand Down Expand Up @@ -1225,7 +1228,7 @@ namespace {
static std::pair<unsigned, unsigned>
ReadKeyDataLength(const uint8_t *&data) {
unsigned keyLength = endian::readNext<uint16_t, little, unaligned>(data);
unsigned dataLength = endian::readNext<uint16_t, little, unaligned>(data);
unsigned dataLength = endian::readNext<uint32_t, little, unaligned>(data);
return { keyLength, dataLength };
}

Expand Down