@@ -660,15 +660,15 @@ void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
660660 auto val = rel.sym ->getVA (ctx, rel.addend ) -
661661 rel1.sym ->getVA (ctx, rel1.addend );
662662 if (overwriteULEB128 (loc, val) >= 0x80 )
663- errorOrWarn ( sec.getLocation (rel.offset ) + " : ULEB128 value " +
664- Twine (val) + " exceeds available space; references '" +
665- lld::toString (*rel.sym ) + " '" ) ;
663+ Err (ctx) << sec.getLocation (rel.offset ) << " : ULEB128 value "
664+ << Twine (val) << " exceeds available space; references '"
665+ << lld::toString (*rel.sym ) << " '" ;
666666 ++i;
667667 continue ;
668668 }
669669 }
670- errorOrWarn ( sec.getLocation (rel.offset ) +
671- " : R_RISCV_SET_ULEB128 not paired with R_RISCV_SUB_SET128" ) ;
670+ Err (ctx) << sec.getLocation (rel.offset )
671+ << " : R_RISCV_SET_ULEB128 not paired with R_RISCV_SUB_SET128" ;
672672 return ;
673673 default :
674674 break ;
@@ -832,12 +832,12 @@ static bool relax(Ctx &ctx, InputSection &sec) {
832832 remove = nextLoc - ((loc + align - 1 ) & -align);
833833 // If we can't satisfy this alignment, we've found a bad input.
834834 if (LLVM_UNLIKELY (static_cast <int32_t >(remove) < 0 )) {
835- errorOrWarn ( getErrorLoc (ctx, (const uint8_t *)loc) +
836- " insufficient padding bytes for " + lld::toString (r.type ) +
837- " : " + Twine (r.addend ) +
838- " bytes available "
839- " for requested alignment of " +
840- Twine (align) + " bytes" ) ;
835+ Err (ctx) << getErrorLoc (ctx, (const uint8_t *)loc)
836+ << " insufficient padding bytes for " << lld::toString (r.type )
837+ << " : " << Twine (r.addend )
838+ << " bytes available "
839+ " for requested alignment of "
840+ << Twine (align) << " bytes" ;
841841 remove = 0 ;
842842 }
843843 break ;
@@ -1064,8 +1064,8 @@ static void mergeArch(RISCVISAUtils::OrderedExtensionMap &mergedExts,
10641064 StringRef s) {
10651065 auto maybeInfo = RISCVISAInfo::parseNormalizedArchString (s);
10661066 if (!maybeInfo) {
1067- errorOrWarn ( toString (sec) + " : " + s + " : " +
1068- llvm::toString (maybeInfo.takeError () ));
1067+ Err (ctx) << sec << " : " << s << " : "
1068+ << llvm::toString (maybeInfo.takeError ());
10691069 return ;
10701070 }
10711071
@@ -1097,11 +1097,11 @@ static void mergeAtomic(DenseMap<unsigned, unsigned>::iterator it,
10971097 return ;
10981098
10991099 auto reportAbiError = [&]() {
1100- errorOrWarn ( " atomic abi mismatch for " + oldSection->name + " \n >>> " +
1101- toString ( oldSection) +
1102- " : atomic_abi=" + Twine (static_cast <unsigned >(oldTag)) +
1103- " \n >>> " + toString ( newSection) +
1104- " : atomic_abi=" + Twine (static_cast <unsigned >(newTag) ));
1100+ Err (ctx) << " atomic abi mismatch for " << oldSection->name << " \n >>> "
1101+ << oldSection
1102+ << " : atomic_abi=" << Twine (static_cast <unsigned >(oldTag))
1103+ << " \n >>> " << newSection
1104+ << " : atomic_abi=" << Twine (static_cast <unsigned >(newTag));
11051105 };
11061106
11071107 auto reportUnknownAbiError = [](const InputSectionBase *section,
@@ -1113,9 +1113,8 @@ static void mergeAtomic(DenseMap<unsigned, unsigned>::iterator it,
11131113 case RISCVAtomicAbiTag::A7:
11141114 return ;
11151115 };
1116- errorOrWarn (" unknown atomic abi for " + section->name + " \n >>> " +
1117- toString (section) +
1118- " : atomic_abi=" + Twine (static_cast <unsigned >(tag)));
1116+ Err (ctx) << " unknown atomic abi for " << section->name << " \n >>> "
1117+ << section << " : atomic_abi=" << Twine (static_cast <unsigned >(tag));
11191118 };
11201119 switch (oldTag) {
11211120 case RISCVAtomicAbiTag::UNKNOWN:
@@ -1200,9 +1199,9 @@ mergeAttributesSection(Ctx &ctx,
12001199 firstStackAlign = sec;
12011200 firstStackAlignValue = *i;
12021201 } else if (r.first ->second != *i) {
1203- errorOrWarn ( toString (sec) + " has stack_align=" + Twine (*i) +
1204- " but " + toString ( firstStackAlign) +
1205- " has stack_align=" + Twine (firstStackAlignValue) );
1202+ Err (ctx) << sec << " has stack_align=" << Twine (*i) << " but "
1203+ << firstStackAlign
1204+ << " has stack_align=" << Twine (firstStackAlignValue);
12061205 }
12071206 }
12081207 continue ;
@@ -1262,7 +1261,7 @@ mergeAttributesSection(Ctx &ctx,
12621261 merged.strAttr .try_emplace (RISCVAttrs::ARCH,
12631262 saver ().save ((*result)->toString ()));
12641263 } else {
1265- errorOrWarn ( llvm::toString (result.takeError () ));
1264+ Err (ctx) << llvm::toString (result.takeError ());
12661265 }
12671266 }
12681267
0 commit comments