@@ -86,7 +86,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args);
8686
8787void elf::errorOrWarn (const Twine &msg) {
8888 if (ctx.arg .noinhibitExec )
89- warn (msg) ;
89+ Warn (ctx) << msg ;
9090 else
9191 ErrAlways (ctx) << msg;
9292}
@@ -346,8 +346,9 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
346346 } else if (magic == file_magic::bitcode)
347347 files.push_back (make<BitcodeFile>(ctx, p.first , path, p.second , true ));
348348 else
349- warn (path + " : archive member '" + p.first .getBufferIdentifier () +
350- " ' is neither ET_REL nor LLVM bitcode" );
349+ Warn (ctx) << path << " : archive member '"
350+ << p.first .getBufferIdentifier ()
351+ << " ' is neither ET_REL nor LLVM bitcode" ;
351352 }
352353 if (!saved.get ())
353354 ++nextGroupId;
@@ -627,7 +628,7 @@ static void checkZOptions(opt::InputArgList &args) {
627628 getZFlag (args, " rel" , " rela" , false );
628629 for (auto *arg : args.filtered (OPT_z))
629630 if (!arg->isClaimed ())
630- warn ( " unknown -z value: " + StringRef (arg->getValue () ));
631+ Warn (ctx) << " unknown -z value: " << StringRef (arg->getValue ());
631632}
632633
633634constexpr const char *saveTempsValues[] = {
@@ -838,11 +839,11 @@ static int getMemtagMode(Ctx &ctx, opt::InputArgList &args) {
838839 StringRef memtagModeArg = args.getLastArgValue (OPT_android_memtag_mode);
839840 if (memtagModeArg.empty ()) {
840841 if (ctx.arg .androidMemtagStack )
841- warn ( " --android-memtag-mode is unspecified, leaving "
842- " --android-memtag-stack a no-op" ) ;
842+ Warn (ctx) << " --android-memtag-mode is unspecified, leaving "
843+ " --android-memtag-stack a no-op" ;
843844 else if (ctx.arg .androidMemtagHeap )
844- warn ( " --android-memtag-mode is unspecified, leaving "
845- " --android-memtag-heap a no-op" ) ;
845+ Warn (ctx) << " --android-memtag-mode is unspecified, leaving "
846+ " --android-memtag-heap a no-op" ;
846847 return ELF::NT_MEMTAG_LEVEL_NONE;
847848 }
848849
@@ -981,7 +982,7 @@ static void readCallGraph(Ctx &ctx, MemoryBufferRef mb) {
981982 Symbol *sym = map.lookup (name);
982983 if (!sym) {
983984 if (ctx.arg .warnSymbolOrdering )
984- warn ( mb.getBufferIdentifier () + " : no such symbol: " + name) ;
985+ Warn (ctx) << mb.getBufferIdentifier () << " : no such symbol: " << name;
985986 return nullptr ;
986987 }
987988 maybeWarnUnorderableSymbol (ctx, sym);
@@ -1054,7 +1055,8 @@ processCallGraphRelocations(Ctx &ctx, SmallVector<uint32_t, 32> &symbolIndices,
10541055 }
10551056 }
10561057 if (symbolIndices.empty ())
1057- warn (" SHT_LLVM_CALL_GRAPH_PROFILE exists, but relocation section doesn't" );
1058+ Warn (ctx)
1059+ << " SHT_LLVM_CALL_GRAPH_PROFILE exists, but relocation section doesn't" ;
10581060 return !symbolIndices.empty ();
10591061}
10601062
@@ -1210,7 +1212,8 @@ static SmallVector<StringRef, 0> getSymbolOrderingFile(Ctx &ctx,
12101212 SetVector<StringRef, SmallVector<StringRef, 0 >> names;
12111213 for (StringRef s : args::getLines (mb))
12121214 if (!names.insert (s) && ctx.arg .warnSymbolOrdering )
1213- warn (mb.getBufferIdentifier () + " : duplicate ordered symbol: " + s);
1215+ Warn (ctx) << mb.getBufferIdentifier ()
1216+ << " : duplicate ordered symbol: " << s;
12141217
12151218 return names.takeVector ();
12161219}
@@ -2118,7 +2121,8 @@ static uint64_t getMaxPageSize(Ctx &ctx, opt::InputArgList &args) {
21182121 }
21192122 if (ctx.arg .nmagic || ctx.arg .omagic ) {
21202123 if (val != ctx.target ->defaultMaxPageSize )
2121- warn (" -z max-page-size set, but paging disabled by omagic or nmagic" );
2124+ Warn (ctx)
2125+ << " -z max-page-size set, but paging disabled by omagic or nmagic" ;
21222126 return 1 ;
21232127 }
21242128 return val;
@@ -2135,7 +2139,8 @@ static uint64_t getCommonPageSize(Ctx &ctx, opt::InputArgList &args) {
21352139 }
21362140 if (ctx.arg .nmagic || ctx.arg .omagic ) {
21372141 if (val != ctx.target ->defaultCommonPageSize )
2138- warn (" -z common-page-size set, but paging disabled by omagic or nmagic" );
2142+ Warn (ctx)
2143+ << " -z common-page-size set, but paging disabled by omagic or nmagic" ;
21392144 return 1 ;
21402145 }
21412146 // commonPageSize can't be larger than maxPageSize.
@@ -2159,7 +2164,7 @@ static std::optional<uint64_t> getImageBase(Ctx &ctx, opt::InputArgList &args) {
21592164 return 0 ;
21602165 }
21612166 if ((v % ctx.arg .maxPageSize ) != 0 )
2162- warn ( " --image-base: address isn't multiple of page size: " + s) ;
2167+ Warn (ctx) << " --image-base: address isn't multiple of page size: " << s ;
21632168 return v;
21642169}
21652170
@@ -2316,8 +2321,8 @@ static void reportBackrefs(Ctx &ctx) {
23162321 break ;
23172322 }
23182323 if (!exclude)
2319- warn ( " backward reference detected: " + sym.getName () + " in " +
2320- toString ( ref.second .first ) + " refers to " + to) ;
2324+ Warn (ctx) << " backward reference detected: " << sym.getName () << " in "
2325+ << ref.second .first << " refers to " << to;
23212326 }
23222327}
23232328
@@ -2434,7 +2439,7 @@ static void findKeepUniqueSections(Ctx &ctx, opt::InputArgList &args) {
24342439 StringRef name = arg->getValue ();
24352440 auto *d = dyn_cast_or_null<Defined>(ctx.symtab ->find (name));
24362441 if (!d || !d->section ) {
2437- warn ( " could not find symbol " + name + " to keep unique" ) ;
2442+ Warn (ctx) << " could not find symbol " << name << " to keep unique" ;
24382443 continue ;
24392444 }
24402445 d->section ->keepUnique = true ;
@@ -2749,7 +2754,7 @@ static void reportMissingFeature(StringRef config, const Twine &report) {
27492754 if (config == " error" )
27502755 ErrAlways (ctx) << report;
27512756 else if (config == " warning" )
2752- warn (report) ;
2757+ Warn (ctx) << report ;
27532758}
27542759
27552760static void checkAndReportMissingFeature (StringRef config, uint32_t features,
@@ -2820,13 +2825,15 @@ static void readSecurityNotes(Ctx &ctx) {
28202825 } else if (ctx.arg .zForceIbt &&
28212826 !(features & GNU_PROPERTY_X86_FEATURE_1_IBT)) {
28222827 if (ctx.arg .zCetReport == " none" )
2823- warn (toString (f) + " : -z force-ibt: file does not have "
2824- " GNU_PROPERTY_X86_FEATURE_1_IBT property" );
2828+ Warn (ctx) << f
2829+ << " : -z force-ibt: file does not have "
2830+ " GNU_PROPERTY_X86_FEATURE_1_IBT property" ;
28252831 features |= GNU_PROPERTY_X86_FEATURE_1_IBT;
28262832 }
28272833 if (ctx.arg .zPacPlt && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
2828- warn (toString (f) + " : -z pac-plt: file does not have "
2829- " GNU_PROPERTY_AARCH64_FEATURE_1_PAC property" );
2834+ Warn (ctx) << f
2835+ << " : -z pac-plt: file does not have "
2836+ " GNU_PROPERTY_AARCH64_FEATURE_1_PAC property" ;
28302837 features |= GNU_PROPERTY_AARCH64_FEATURE_1_PAC;
28312838 }
28322839 ctx.arg .andFeatures &= features;
0 commit comments