diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp index e253aab8c08f..62685b1e7ded 100644 --- a/lld/ELF/Arch/ARM.cpp +++ b/lld/ELF/Arch/ARM.cpp @@ -557,8 +557,8 @@ void ARM::encodeAluGroup(uint8_t *loc, const Relocation &rel, uint64_t val, rot = (lz + 8) << 7; } if (check && imm > 0xff) - Err(ctx) << getErrorLoc(ctx, loc) << "unencodeable immediate " - << Twine(val).str() << " for relocation " << rel.type; + Err(ctx) << getErrorLoc(ctx, loc) << "unencodeable immediate " << val + << " for relocation " << rel.type; write32(ctx, loc, (read32(ctx, loc) & 0xff3ff000) | opcode | rot | (imm & 0xff)); } @@ -1238,8 +1238,8 @@ template void ObjFile::importCmseSymbols() { if (eSym.st_size != ACLESESYM_SIZE) { Warn(ctx) << "CMSE symbol '" << sym->getName() << "' in import library '" - << this << "' does not have correct size of " - << Twine(ACLESESYM_SIZE) << " bytes"; + << this << "' does not have correct size of " << ACLESESYM_SIZE + << " bytes"; } ctx.symtab->cmseImportLib[sym->getName()] = sym; diff --git a/lld/ELF/Arch/LoongArch.cpp b/lld/ELF/Arch/LoongArch.cpp index 0eb56de9c7f3..ebfdbafc9983 100644 --- a/lld/ELF/Arch/LoongArch.cpp +++ b/lld/ELF/Arch/LoongArch.cpp @@ -775,8 +775,8 @@ static bool relax(Ctx &ctx, InputSection &sec) { if (LLVM_UNLIKELY(static_cast(remove) < 0)) { Err(ctx) << getErrorLoc(ctx, (const uint8_t *)loc) << "insufficient padding bytes for " << r.type << ": " - << Twine(allBytes) << " bytes available for " - << "requested alignment of " << Twine(align) << " bytes"; + << allBytes << " bytes available for " + << "requested alignment of " << align << " bytes"; remove = 0; } break; @@ -807,7 +807,7 @@ static bool relax(Ctx &ctx, InputSection &sec) { } // Inform assignAddresses that the size has changed. if (!isUInt<32>(delta)) - Fatal(ctx) << "section size decrease is too large: " << Twine(delta); + Fatal(ctx) << "section size decrease is too large: " << delta; sec.bytesDropped = delta; return changed; } @@ -838,7 +838,7 @@ bool LoongArch::relaxOnce(int pass) const { } void LoongArch::finalizeRelax(int passes) const { - Log(ctx) << "relaxation passes: " << Twine(passes); + Log(ctx) << "relaxation passes: " << passes; SmallVector storage; for (OutputSection *osec : ctx.outputSections) { if (!(osec->flags & SHF_EXECINSTR)) diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp index 02f360d73ea1..da76820de240 100644 --- a/lld/ELF/Arch/Mips.cpp +++ b/lld/ELF/Arch/Mips.cpp @@ -503,7 +503,7 @@ calculateMipsRelChain(Ctx &ctx, uint8_t *loc, uint32_t type, uint64_t val) { if (type2 == R_MIPS_SUB && (type3 == R_MIPS_HI16 || type3 == R_MIPS_LO16)) return std::make_pair(type3, -val); Err(ctx) << getErrorLoc(ctx, loc) << "unsupported relocations combination " - << Twine(type); + << type; return std::make_pair(type & 0xff, val); } diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp index 21e8e9db311a..58a71fd9545c 100644 --- a/lld/ELF/Arch/RISCV.cpp +++ b/lld/ELF/Arch/RISCV.cpp @@ -658,9 +658,9 @@ void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const { auto val = rel.sym->getVA(ctx, rel.addend) - rel1.sym->getVA(ctx, rel1.addend); if (overwriteULEB128(loc, val) >= 0x80) - Err(ctx) << sec.getLocation(rel.offset) << ": ULEB128 value " - << Twine(val) << " exceeds available space; references '" - << rel.sym << "'"; + Err(ctx) << sec.getLocation(rel.offset) << ": ULEB128 value " << val + << " exceeds available space; references '" << rel.sym + << "'"; ++i; continue; } @@ -832,10 +832,10 @@ static bool relax(Ctx &ctx, InputSection &sec) { if (LLVM_UNLIKELY(static_cast(remove) < 0)) { Err(ctx) << getErrorLoc(ctx, (const uint8_t *)loc) << "insufficient padding bytes for " << r.type << ": " - << Twine(r.addend) + << r.addend << " bytes available " "for requested alignment of " - << Twine(align) << " bytes"; + << align << " bytes"; remove = 0; } break; @@ -899,7 +899,7 @@ static bool relax(Ctx &ctx, InputSection &sec) { } // Inform assignAddresses that the size has changed. if (!isUInt<32>(delta)) - Fatal(ctx) << "section size decrease is too large: " << Twine(delta); + Fatal(ctx) << "section size decrease is too large: " << delta; sec.bytesDropped = delta; return changed; } @@ -932,7 +932,7 @@ bool RISCV::relaxOnce(int pass) const { void RISCV::finalizeRelax(int passes) const { llvm::TimeTraceScope timeScope("Finalize RISC-V relaxation"); - Log(ctx) << "relaxation passes: " << Twine(passes); + Log(ctx) << "relaxation passes: " << passes; SmallVector storage; for (OutputSection *osec : ctx.outputSections) { if (!(osec->flags & SHF_EXECINSTR)) @@ -1095,10 +1095,9 @@ static void mergeAtomic(Ctx &ctx, DenseMap::iterator it, auto reportAbiError = [&]() { Err(ctx) << "atomic abi mismatch for " << oldSection->name << "\n>>> " - << oldSection - << ": atomic_abi=" << Twine(static_cast(oldTag)) + << oldSection << ": atomic_abi=" << static_cast(oldTag) << "\n>>> " << newSection - << ": atomic_abi=" << Twine(static_cast(newTag)); + << ": atomic_abi=" << static_cast(newTag); }; auto reportUnknownAbiError = [&](const InputSectionBase *section, @@ -1111,7 +1110,7 @@ static void mergeAtomic(Ctx &ctx, DenseMap::iterator it, return; }; Err(ctx) << "unknown atomic abi for " << section->name << "\n>>> " - << section << ": atomic_abi=" << Twine(static_cast(tag)); + << section << ": atomic_abi=" << static_cast(tag); }; switch (oldTag) { case RISCVAtomicAbiTag::UNKNOWN: diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index db0d185c0c09..bc4b967ccbbb 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -1327,15 +1327,13 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { OPT_no_lto_validate_all_vtables_have_type_infos, false); ctx.arg.ltoo = args::getInteger(args, OPT_lto_O, 2); if (ctx.arg.ltoo > 3) - ErrAlways(ctx) << "invalid optimization level for LTO: " - << Twine(ctx.arg.ltoo); + ErrAlways(ctx) << "invalid optimization level for LTO: " << ctx.arg.ltoo; unsigned ltoCgo = args::getInteger(args, OPT_lto_CGO, args::getCGOptLevel(ctx.arg.ltoo)); if (auto level = CodeGenOpt::getLevel(ltoCgo)) ctx.arg.ltoCgo = *level; else - ErrAlways(ctx) << "invalid codegen optimization level for LTO: " - << Twine(ltoCgo); + ErrAlways(ctx) << "invalid codegen optimization level for LTO: " << ltoCgo; ctx.arg.ltoObjPath = args.getLastArgValue(OPT_lto_obj_path_eq); ctx.arg.ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1); ctx.arg.ltoSampleProfile = args.getLastArgValue(OPT_lto_sample_profile); diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index 7090ca779b0e..606953e94bba 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -542,7 +542,7 @@ template void ICF::run() { }); } while (repeat); - Log(ctx) << "ICF needed " << Twine(cnt) << " iterations"; + Log(ctx) << "ICF needed " << cnt << " iterations"; // Merge sections by the equivalence class. forEachClassRange(0, sections.size(), [&](size_t begin, size_t end) { diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 07c8f1d1a679..83a25e1b66cf 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -133,8 +133,7 @@ static void updateARMVFPArgs(Ctx &ctx, const ARMAttributeParser &attributes, // Object compatible with all conventions. return; default: - ErrAlways(ctx) << f - << ": unknown Tag_ABI_VFP_args value: " << Twine(vfpArgs); + ErrAlways(ctx) << f << ": unknown Tag_ABI_VFP_args value: " << vfpArgs; return; } // Follow ld.bfd and error if there is a mix of calling conventions. @@ -691,8 +690,7 @@ template void ObjFile::parse(bool ignoreComdats) { // Otherwise, discard group members. for (uint32_t secIndex : entries.slice(1)) { if (secIndex >= size) - Fatal(ctx) << this - << ": invalid section index in group: " << Twine(secIndex); + Fatal(ctx) << this << ": invalid section index in group: " << secIndex; this->sections[secIndex] = &InputSection::discarded; } } @@ -748,8 +746,8 @@ bool ObjFile::shouldMerge(const Elf_Shdr &sec, StringRef name) { return false; if (sec.sh_size % entSize) Fatal(ctx) << this << ":(" << name << "): SHF_MERGE section size (" - << Twine(sec.sh_size) << ") must be a multiple of sh_entsize (" - << Twine(entSize) << ")"; + << uint64_t(sec.sh_size) + << ") must be a multiple of sh_entsize (" << entSize << ")"; if (sec.sh_flags & SHF_WRITE) Fatal(ctx) << this << ":(" << name @@ -810,7 +808,7 @@ void ObjFile::initializeSections(bool ignoreComdats, Warn(ctx) << this << ": --icf=safe conservatively ignores " "SHT_LLVM_ADDRSIG [index " - << Twine(i) + << i << "] with sh_link=0 " "(likely created using objcopy or ld -r)"; } @@ -939,7 +937,8 @@ void ObjFile::initializeSections(bool ignoreComdats, if (sec.sh_link < size) linkSec = this->sections[sec.sh_link]; if (!linkSec) - Fatal(ctx) << this << ": invalid sh_link index: " << Twine(sec.sh_link); + Fatal(ctx) << this + << ": invalid sh_link index: " << uint32_t(sec.sh_link); // A SHF_LINK_ORDER section is discarded if its linked-to section is // discarded. @@ -1167,7 +1166,7 @@ void ObjFile::initializeSymbols(const object::ELFFile &obj) { if (LLVM_UNLIKELY(eSym.st_shndx == SHN_COMMON)) { if (value == 0 || value >= UINT32_MAX) Fatal(ctx) << this << ": common symbol '" << sym->getName() - << "' has invalid alignment: " << Twine(value); + << "' has invalid alignment: " << value; hasCommonSyms = true; sym->resolve(ctx, CommonSymbol{ctx, this, StringRef(), binding, stOther, type, value, size}); @@ -1214,7 +1213,7 @@ void ObjFile::initSectionsAndLocalSyms(bool ignoreComdats) { else if (secIdx >= SHN_LORESERVE) secIdx = 0; if (LLVM_UNLIKELY(secIdx >= sections.size())) - Fatal(ctx) << this << ": invalid section index: " << Twine(secIdx); + Fatal(ctx) << this << ": invalid section index: " << secIdx; if (LLVM_UNLIKELY(eSym.getBinding() != STB_LOCAL)) ErrAlways(ctx) << this << ": non-local symbol (" << i << ") found at index < .symtab's sh_info (" << end << ")"; @@ -1274,7 +1273,7 @@ template void ObjFile::postParse() { else if (secIdx >= SHN_LORESERVE) secIdx = 0; if (LLVM_UNLIKELY(secIdx >= sections.size())) - Fatal(ctx) << this << ": invalid section index: " << Twine(secIdx); + Fatal(ctx) << this << ": invalid section index: " << secIdx; InputSectionBase *sec = sections[secIdx]; if (sec == &InputSection::discarded) { if (sym.traced) { @@ -1577,8 +1576,8 @@ template void SharedFile::parse() { // as of binutils 2.34, GNU ld produces VER_NDX_LOCAL. if (ver != VER_NDX_LOCAL && ver != VER_NDX_GLOBAL) { if (idx >= verneeds.size()) { - ErrAlways(ctx) << "corrupt input file: version need index " - << Twine(idx) << " for symbol " << name + ErrAlways(ctx) << "corrupt input file: version need index " << idx + << " for symbol " << name << " is out of bounds\n>>> defined in " << this; continue; } @@ -1602,8 +1601,8 @@ template void SharedFile::parse() { // VER_NDX_LOCAL. Workaround this bug. if (ctx.arg.emachine == EM_MIPS && name == "_gp_disp") continue; - ErrAlways(ctx) << "corrupt input file: version definition index " - << Twine(idx) << " for symbol " << name + ErrAlways(ctx) << "corrupt input file: version definition index " << idx + << " for symbol " << name << " is out of bounds\n>>> defined in " << this; continue; } diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 0a1b742a4ccf..1f69e4c9acbb 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -274,7 +274,7 @@ void InputSectionBase::parseCompressedHeader(Ctx &ctx) { "not built with zstd support"; } else { ErrAlways(ctx) << this << ": unsupported compression type (" - << Twine(hdr->ch_type) << ")"; + << uint32_t(hdr->ch_type) << ")"; return; } diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 8ff6e2cd3a9d..7d24c6750b0d 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1784,7 +1784,7 @@ static void checkMemoryRegion(Ctx &ctx, const MemoryRegion *region, if (osecEnd > regionEnd) { ErrAlways(ctx) << "section '" << osec->name << "' will not fit in region '" << region->name << "': overflowed by " - << Twine(osecEnd - regionEnd) << " bytes"; + << (osecEnd - regionEnd) << " bytes"; } } diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index a275d15a6e57..21fe2a25fa1b 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2116,8 +2116,8 @@ template bool RelrSection::updateAllocSize(Ctx &ctx) { // Don't allow the section to shrink; otherwise the size of the section can // oscillate infinitely. Trailing 1s do not decode to more relocations. if (relrRelocs.size() < oldSize) { - Log(ctx) << ".relr.dyn needs " << Twine(oldSize - relrRelocs.size()) << - " padding word(s)"; + Log(ctx) << ".relr.dyn needs " << (oldSize - relrRelocs.size()) + << " padding word(s)"; relrRelocs.resize(oldSize, Elf_Relr(1)); } @@ -2870,7 +2870,7 @@ void DebugNamesBaseSection::parseDebugNames( nd.hdr = ni.getHeader(); if (nd.hdr.Format != DwarfFormat::DWARF32) { Err(ctx) << namesSec.sec - << Twine(": found DWARF64, which is currently unsupported"); + << ": found DWARF64, which is currently unsupported"; return; } if (nd.hdr.Version != 5) { @@ -2880,8 +2880,7 @@ void DebugNamesBaseSection::parseDebugNames( uint32_t dwarfSize = dwarf::getDwarfOffsetByteSize(DwarfFormat::DWARF32); DWARFDebugNames::DWARFDebugNamesOffsets locs = ni.getOffsets(); if (locs.EntriesBase > namesExtractor.getData().size()) { - Err(ctx) << namesSec.sec - << Twine(": entry pool start is beyond end of section"); + Err(ctx) << namesSec.sec << ": entry pool start is beyond end of section"; return; } @@ -2962,7 +2961,7 @@ void DebugNamesBaseSection::computeHdrAndAbbrevTable( // ForeignTypeUnitCount are left as 0. if (nd.hdr.LocalTypeUnitCount || nd.hdr.ForeignTypeUnitCount) Warn(ctx) << inputChunk.section.sec - << Twine(": type units are not implemented"); + << ": type units are not implemented"; // If augmentation strings are not identical, use an empty string. if (i == 0) { hdr.AugmentationStringSize = nd.hdr.AugmentationStringSize; diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 203252dbac12..63d813e550f9 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -84,7 +84,7 @@ void elf::setTarget(Ctx &ctx) { case EM_X86_64: return setX86_64TargetInfo(ctx); default: - Fatal(ctx) << "unsupported e_machine value: " << Twine(ctx.arg.emachine); + Fatal(ctx) << "unsupported e_machine value: " << ctx.arg.emachine; } } diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index a772a9d3bb50..fd1e5d33c438 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -292,7 +292,7 @@ inline void checkAlignment(Ctx &ctx, uint8_t *loc, uint64_t v, int n, if ((v & (n - 1)) != 0) Err(ctx) << getErrorLoc(ctx, loc) << "improper alignment for relocation " << rel.type << ": 0x" << llvm::utohexstr(v) - << " is not aligned to " << Twine(n) << " bytes"; + << " is not aligned to " << n << " bytes"; } // Endianness-aware read/write. diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 67497bad7cb2..a7fbdc079070 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1572,8 +1572,8 @@ template void Writer::finalizeAddressDependentContent() { if (osec->addr % osec->addralign != 0) Warn(ctx) << "address (0x" << Twine::utohexstr(osec->addr) << ") of section " << osec->name - << " is not a multiple of alignment (" - << Twine(osec->addralign) << ")"; + << " is not a multiple of alignment (" << osec->addralign + << ")"; } // Sizes are no longer allowed to grow, so all allowable spills have been @@ -2794,7 +2794,7 @@ template void Writer::openFile() { if (fileSize != size_t(fileSize) || maxSize < fileSize) { std::string msg; raw_string_ostream s(msg); - s << "output file too large: " << Twine(fileSize) << " bytes\n" + s << "output file too large: " << fileSize << " bytes\n" << "section sizes:\n"; for (OutputSection *os : ctx.outputSections) s << os->name << ' ' << os->size << "\n";