Skip to content

Commit 3b75a5c

Browse files
committed
[ELF] Replace message(...) with Msg(ctx)
1 parent ce13dd1 commit 3b75a5c

File tree

8 files changed

+17
-10
lines changed

8 files changed

+17
-10
lines changed

lld/Common/ErrorHandler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ SyncStream::~SyncStream() {
342342
case DiagLevel::Log:
343343
e.log(buf);
344344
break;
345+
case DiagLevel::Msg:
346+
e.message(buf, llvm::outs());
347+
break;
345348
case DiagLevel::Warn:
346349
e.warn(buf);
347350
break;

lld/ELF/Config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,9 @@ inline const ELFSyncStream &operator<<(const ELFSyncStream &s, Error v) {
710710
// Report a log if --verbose is specified.
711711
ELFSyncStream Log(Ctx &ctx);
712712

713+
// Print a message to stdout.
714+
ELFSyncStream Msg(Ctx &ctx);
715+
713716
// Report a warning. Upgraded to an error if --fatal-warnings is specified.
714717
ELFSyncStream Warn(Ctx &ctx);
715718

lld/ELF/Driver.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static void setConfigs(Ctx &ctx, opt::InputArgList &args);
8585
static void readConfigs(Ctx &ctx, opt::InputArgList &args);
8686

8787
ELFSyncStream elf::Log(Ctx &ctx) { return {ctx, DiagLevel::Log}; }
88+
ELFSyncStream elf::Msg(Ctx &ctx) { return {ctx, DiagLevel::Msg}; }
8889
ELFSyncStream elf::Warn(Ctx &ctx) { return {ctx, DiagLevel::Warn}; }
8990
ELFSyncStream elf::Err(Ctx &ctx) {
9091
return {ctx, ctx.arg.noinhibitExec ? DiagLevel::Warn : DiagLevel::Err};
@@ -672,7 +673,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
672673
// of Libtool. We cannot convince every software developer to migrate to
673674
// the latest version and re-generate scripts. So we have this hack.
674675
if (args.hasArg(OPT_v) || args.hasArg(OPT_version))
675-
message(getLLDVersion() + " (compatible with GNU linkers)");
676+
Msg(ctx) << getLLDVersion() << " (compatible with GNU linkers)";
676677

677678
if (const char *path = getReproduceOption(args)) {
678679
// Note that --reproduce is a debug option so you can ignore it
@@ -1151,10 +1152,10 @@ static void ltoValidateAllVtablesHaveTypeInfos(Ctx &ctx,
11511152
ctx.ltoAllVtablesHaveTypeInfos = vtableSymbolsWithNoRTTI.empty();
11521153
// Check for unmatched RTTI symbols
11531154
for (StringRef s : vtableSymbolsWithNoRTTI) {
1154-
message(
1155-
"--lto-validate-all-vtables-have-type-infos: RTTI missing for vtable "
1156-
"_ZTV" +
1157-
s + ", --lto-whole-program-visibility disabled");
1155+
Msg(ctx) << "--lto-validate-all-vtables-have-type-infos: RTTI missing for "
1156+
"vtable "
1157+
"_ZTV"
1158+
<< s << ", --lto-whole-program-visibility disabled";
11581159
}
11591160
}
11601161

lld/ELF/ICF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static void combineRelocHashes(unsigned cnt, InputSection *isec,
461461

462462
static void print(Ctx &ctx, const Twine &s) {
463463
if (ctx.arg.printIcfSections)
464-
message(s);
464+
Msg(ctx) << s;
465465
}
466466

467467
// The main function of ICF.

lld/ELF/InputFiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ template <class ELFT> static void doParseFile(Ctx &ctx, InputFile *file) {
316316
}
317317

318318
if (ctx.arg.trace)
319-
message(toStr(ctx, file));
319+
Msg(ctx) << file;
320320

321321
if (file->kind() == InputFile::ObjKind) {
322322
ctx.objectFiles.push_back(cast<ELFFileBase>(file));

lld/ELF/MarkLive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ template <class ELFT> void elf::markLive(Ctx &ctx) {
391391
if (ctx.arg.printGcSections)
392392
for (InputSectionBase *sec : ctx.inputSections)
393393
if (!sec->isLive())
394-
message("removing unused section " + toStr(ctx, sec));
394+
Msg(ctx) << "removing unused section " << sec;
395395
}
396396

397397
template void elf::markLive<ELF32LE>(Ctx &);

lld/ELF/Symbols.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void elf::printTraceSymbol(const Symbol &sym, StringRef name) {
295295
else
296296
s = ": definition of ";
297297

298-
message(toStr(sym.file->ctx, sym.file) + s + name);
298+
Msg(ctx) << toStr(sym.file->ctx, sym.file) << s << name;
299299
}
300300

301301
static void recordWhyExtract(Ctx &ctx, const InputFile *reference,

lld/include/lld/Common/ErrorHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void message(const Twine &msg, llvm::raw_ostream &s = outs());
152152
void warn(const Twine &msg);
153153
uint64_t errorCount();
154154

155-
enum class DiagLevel { Log, Warn, Err, Fatal };
155+
enum class DiagLevel { Log, Msg, Warn, Err, Fatal };
156156

157157
// A class that synchronizes thread writing to the same stream similar
158158
// std::osyncstream.

0 commit comments

Comments
 (0)