Make sure strings don't get too big for a record, truncate them if
need-be.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273710
91177308-0d34-0410-b5e6-
96231b3b80d8
return ContinuationOffsets.empty() ? 0 : ContinuationOffsets.back();
}
size_t getLastContinuationEnd() const { return Builder.size(); }
- unsigned getLastContinuationSize() const {
+ size_t getLastContinuationSize() const {
return getLastContinuationEnd() - getLastContinuationStart();
}
void writeEncodedInteger(int64_t Value);
void writeEncodedSignedInteger(int64_t Value);
void writeEncodedUnsignedInteger(uint64_t Value);
- void writeNullTerminatedString(const char *Value);
void writeNullTerminatedString(StringRef Value);
void writeGuid(StringRef Guid);
void writeBytes(StringRef Value) { Stream << Value; }
// back up and insert a continuation record, sliding the current subrecord
// down.
if (getLastContinuationSize() > 65535 - 8) {
+ assert(SubrecordStart != 0 && "can't slide from the start!");
SmallString<128> SubrecordCopy(
Builder.str().slice(SubrecordStart, Builder.size()));
+ assert(SubrecordCopy.size() < 65530 && "subrecord is too large to slide!");
Builder.truncate(SubrecordStart);
// Write a placeholder continuation record.
}
}
-void TypeRecordBuilder::writeNullTerminatedString(const char *Value) {
- assert(Value != nullptr);
-
- size_t Length = strlen(Value);
- Stream.write(Value, Length);
- writeUInt8(0);
-}
-
void TypeRecordBuilder::writeNullTerminatedString(StringRef Value) {
+ // Microsoft's linker seems to have trouble with symbol names longer than
+ // 0xffd8 bytes.
+ Value = Value.substr(0, 0xffd8);
Stream.write(Value.data(), Value.size());
writeUInt8(0);
}