Instead of a series of string operations, use snprintf().

llvm-svn: 295138
This commit is contained in:
Rui Ueyama 2017-02-15 01:09:40 +00:00
parent a39d148aa4
commit aae04a9aa0
1 changed files with 2 additions and 4 deletions

View File

@ -434,10 +434,8 @@ void WinCOFFObjectWriter::SetSectionName(COFFSection &S) {
uint64_t StringTableEntry = Strings.getOffset(S.Name);
if (StringTableEntry <= Max7DecimalOffset) {
SmallVector<char, COFF::NameSize> Buffer;
Twine('/').concat(Twine(StringTableEntry)).toVector(Buffer);
assert(Buffer.size() <= COFF::NameSize && Buffer.size() >= 2);
std::memcpy(S.Header.Name, Buffer.data(), Buffer.size());
snprintf(S.Header.Name, sizeof(S.Header.Name), "/%" PRIu64,
StringTableEntry);
return;
}
if (StringTableEntry <= MaxBase64Offset) {